Struts 1.x 和tiles 1.1 集成

发布于 2024-09-27 04:35:44 字数 2176 浏览 2 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文