Struts 1.x 和tiles 1.1 集成
我正在尝试将 struts 1.x 与tiles 1.1 集成,但我遇到了问题。
这是 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 path="/listcategories"
type="com.wrox.begjsp.ch28.bookstore.controller.ListCategoriesAction"
scope="request">
<forward name="success" path="list.categories"/>
</action>
<!-- ..... -->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-debug" value="2" />
<set-property property="definitions-parser-details" value="2" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
</struts-config>
这是tiles-defs.xml 的片段(从 struts-config.xml 引用):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name="view.abstract" path="/WEB-INF/jsp/layout/standard-layout.jsp">
<put name="header" value="/WEB-INF/jsp/tiles/header.jsp" />
<put name="menu" value="bookstore.menu" />
<put name="base" value="/WEB-INF/jsp/tiles/base.jsp" />
</definition>
<definition name="list.categories" extends="view.abstract">
<put name="body" value="/WEB-INF/jsp/tiles/category-list.jsp" />
</definition>
</tiles-definitions>
当 com.wrox.begjsp.ch28.bookstore.controller.ListCategoriesAction Action 成功时,我们会得到一些奇怪的异常声明,路径属性不能有一个不以 / 开头的值,即“list.categories”,这意味着它不能解释这不是路径,而是在tiles-defs.xml中定义的定义。
我不是瓷砖大师,但我想应该知道如何解读这个值!
I am trying to integrate struts 1.x with tiles 1.1 but I am facing problems.
Here's snippet of 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 path="/listcategories"
type="com.wrox.begjsp.ch28.bookstore.controller.ListCategoriesAction"
scope="request">
<forward name="success" path="list.categories"/>
</action>
<!-- ..... -->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-debug" value="2" />
<set-property property="definitions-parser-details" value="2" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
</struts-config>
And here's snippet of tiles-defs.xml (referenced from struts-config.xml):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name="view.abstract" path="/WEB-INF/jsp/layout/standard-layout.jsp">
<put name="header" value="/WEB-INF/jsp/tiles/header.jsp" />
<put name="menu" value="bookstore.menu" />
<put name="base" value="/WEB-INF/jsp/tiles/base.jsp" />
</definition>
<definition name="list.categories" extends="view.abstract">
<put name="body" value="/WEB-INF/jsp/tiles/category-list.jsp" />
</definition>
</tiles-definitions>
When com.wrox.begjsp.ch28.bookstore.controller.ListCategoriesAction Action succeed, we get some strange exception stating that, the path attribute cannot have a value doesn't starting by / which is "list.categories", which means, it cannot interpret that is not a path but a definition defined in tiles-defs.xml.
I am not a tiles guru, but I think it should know how to interpret this value!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论