可以在Struts1中使用Tiles2吗?
我已经按照迁移指南http://tiles.apache.org/migration/index.html上的说明进行了操作
但是当我尝试访问我的操作时,我得到了这个错误:
org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' not found.我在struts-config.xml中有:
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"
maxFileSize="10M" tempDir="/tmp" />
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
</plug-in>和tiles defs.xml
<definition name="mainTemplate" template="/common/templates/mainTemplate.jsp" />
<definition name="index" extends="mainTemplate">
<put-attribute name="body" type="string" value="/views/index/index.jsp" />
</definition>发布于 2012-12-18 03:11:08
在struts-config.xml中进行以下更改
<controller processorClass=”org.apache.struts.tiles2.TilesRequestProcessor”/>
<plug-in className=”org.apache.struts.tiles2.TilesPlugin” >查找Tiles2插件here的源代码。
发布于 2012-12-18 18:26:08
是的,它可以和struts一起使用。1。Check their site。
将属性放入mainTemplate的平铺文件中,如下所示:
<definition name="mainTemplate" path="/common/templates/mainTemplate.jsp">
<put name="title" value="Tiles Example" />
<put name="header" value="/header.jsp" />
<put name="menu" value="/menu.jsp" />
<put name="body" value="/body.jsp" />
<put name="footer" value="/footer.jsp" />
</definition>如果这不起作用,请尝试更改您的struts-config.xml,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<action-mappings>
<action
path="/User"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/user/user-form.jsp"/>
</action-mappings>
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml"/>
</plug-in>
</struts-config>https://stackoverflow.com/questions/13765077
复制相似问题