我在启用表达式语言以在 tile 配置文件中工作时遇到问题。Spring MVC 版本是 3.2.4,tiles 版本是 3.0.3
我错过了什么?瓷砖配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="base.definition" preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer"
template="/WEB-INF/jsp/layout.jsp">
<put-attribute name="title" expression="${page-title}" />
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
</definition>
<definition name="contact" extends="base.definition">
<put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
</definition>
</tiles-definitions>
弹簧配置:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions" >
<list>
<value>/WEB-INF/tiles-config.xml</value>
</list>
</property>
<property name="checkRefresh" value="true" />
<property name="useMutableTilesContainer" value="true" />
</bean>
在 layout.jsp 我有:
<title><tiles:insertAttribute name="title" ignore="true"/></title>
在控制器中,我试图以这种方式设置页面标题:
@RequestMapping("/index")
public String listContacts(Map<String, Object> map, HttpServletRequest request) {
map.put("contact", new Contact());
map.put("contactList", contactService.listContact());
map.put("page-title", "Episys");
request.getSession().setAttribute("page-title", "Episys");
request.setAttribute("page-title", "Episys");
return "contact";
}
我错过了什么?
提前致谢。