2
我一直在我的應用程序中使用瓷磚2,Thymeleaf和Spring MVC。今天我去添加一個新的片段,它似乎沒有註冊。我仍然得到舊的模板。模板解析器似乎忽略了新的片段。我試過清理我的項目,但它沒有改變任何東西。有誰知道爲什麼我不能添加這個新的瓷磚片段?無法添加新瓷磚片段[瓷磚2,春天,百里香]
彈簧thymeleaf-tiles.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- thymeleaf view resolvers with tiles integration -->
<bean id="tilesConfigurer"
class="org.thymeleaf.extras.tiles2.spring4.web.configurer.ThymeleafTilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/tiles.xml</value>
</list>
</property>
</bean>
<!-- template resolver -->
<bean id="templateResolver"
class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/tiles/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
<property name="characterEncoding" value="utf-8" />
<property name="cacheable" value="false" />
</bean>
<!-- template engine -->
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
<property name="additionalDialects">
<set>
<bean id="tilesDialect" class="org.thymeleaf.extras.tiles2.dialect.TilesDialect" />
</set>
</property>
</bean>
<!-- tiles view resolver -->
<bean id="tilesViewResolver" class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="viewClass"
value="org.thymeleaf.extras.tiles2.spring4.web.view.ThymeleafTilesView" />
<property name="templateEngine" ref="templateEngine" />
<property name="characterEncoding" value="utf-8" />
<property name="order" value="1" />
</bean>
</beans>
tiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN" "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<!-- index -->
<definition name="login" template="templates/login">
<put-attribute name="head" value="fragments/head :: login_head" />
<put-attribute name="content" value="content/login :: content" />
<put-attribute name="privacy_policy" value="fragments/privacy_policy :: privacy_policy" />
<put-attribute name="scripts" value="fragments/scripts :: loginScripts" />
</definition>
<!-- user -->
<definition name="dashboard" template="templates/dashboard">
<put-attribute name="head" value="fragments/head :: dashboard_head" />
<put-attribute name="header" value="fragments/header :: header" />
<put-attribute name="sidebar" value="fragments/sidebar :: sidebar" />
<put-attribute name="footer" value="fragments/footer :: footer" />
<put-attribute name="content" value="content/dashboard :: content" />
<put-attribute name="privacy_policy" value="fragments/privacy_policy :: privacy_policy" />
<put-attribute name="scripts" value="fragments/scripts :: dashboardScripts" />
</definition>
<definition name="profile" extends="dashboard">
<put-attribute name="content" value="content/profile :: content" />
</definition>
<definition name="assets" extends="dashboard">
<put-attribute name="content" value="content/assets :: content" />
</definition>
</tiles-definitions>
的login.html(模板)
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:tiles="http://www.thymeleaf.org">
<th:block tiles:include="head" th:remove="tag" />
<body>
<!-- html -->
<div id="page">
<th:block tiles:include="content" th:remove="tag" />
<th:block tiles:inlcude="privacy_policy" th:remove="tag" />
<th:block tiles:include="scripts" th:remove="tag" />
</div>
</body>
</html>
privacy_policy.html(新片段)
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:tiles="http://www.thymeleaf.org">
<body>
<th:block tiles:fragment="privacy_policy" th:remove="tag">
<div class="jumbotron">ASDFASDFASDF</div>
<h1>ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF</h1>
</th:block>
</body>
</html>
編輯
我可以拼寫錯誤強制從磚錯誤的屬性在我的瓷磚定義。
...
<definition name="login" template="templates/login">
<put-attribute name="head" value="fragments/head :: login_MISSPELLED" />
...
但沒有錯誤,如果我做出改變,以新的片段
...
<definition name="login" template="templates/login">
<put-attribute name="privacy_policy" value="fragments/privacy_policy :: privacy_MISSPELLED" />
...
它肯定,似乎有什麼東西被緩存的,我有一個模板解析器的緩存錯誤的屬性集。我不確定這裏還會發生什麼。 – oxenfree
我已經嘗試過tomcat清理乾淨的工作模塊目錄。我也嘗試了maven clean項目。兩者都不起作用。我在這裏錯過了一些無聊的東西嗎? – oxenfree
我嘗試了拆分整個項目文件夾,重新制作所有代碼,然後重新構建,但仍然在撓撓我的腦袋。 – oxenfree