有人可以用apache瓷砖帮我吗?我遵循各种教程但无法显示相应的文件。
弹簧servlet.xml中:
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.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="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
</bean>
我的/WEB-INF/tiles.xml
<tiles-definitions>
<definition name="base.definition" template="/WEB-INF/jsp/layout.jsp">
<put-attribute name="title" value=""/>
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp"/>
<put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp"></put-attribute>
<put-attribute name="body" value=""/>
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp"></put-attribute>
</definition>
<definition name="hello" extends="base.definition">
<put-attribute name="title" value="Beign java guys | tiles interagion"></put-attribute>
<put-attribute name="body" value="/WEB-INF/jsp/hello.jsp"></put-attribute>
</definition>
layout.jsp
<table border="1" cellspacing="2" align="center">
<tr>
<td height="30" colspan="2"><tiles:insertAttribute name="header" /></td>
</tr>
<tr>
<td height="250" width="150"><tiles:insertAttribute name="menu" /></td>
<td width="400"><tiles:insertAttribute name="body" /></td>
</tr>
<tr><td height="30" colspan="2"><tiles:insertAttribute name="footer" /></td>
</tr>
</table>
所以当我执行代码时,它只显示hello.jsp中的文本,但不显示header.jsp或footer.jsp中的内容
答案 0 :(得分:0)
您的配置很好,但Tiles尚未正确安装
将解析器和配置器更改为
<bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.tiles3.TilesViewResolver">
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>