让我知道如何从调度程序和应用程序上下文初始化切片,如果web.xml中需要进行任何更改, 这是我的tiles.xml
<definition name="contact" extends="mainLayout">
<put-attribute name="title" value="Contact Manager" />
<put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
</definition>
</tiles-definitions>
在应用程序上下文中我使用了
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="requestContextAttribute" value="requestContext"/>
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
和调度程序看起来像这样
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
indexController的&LT; /丙&GT; - &GT; newController
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesConfigurer">
<property name="definitions">
<list>
<value>WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles2.TilesView
</value>
</property>
答案 0 :(得分:1)
在Dispatcher-Servlet中
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
在web.xml中使用此代码
<listener>
<listener-class>org.apache.tiles.web.startup.simple.SimpleTilesListener</listener-class>
</listener>
spring-tiles应用程序不需要休息,tiles.xml取决于您的要求