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