1

我有一个包含 struts 1 和 struts 2 的 java webapp。在应用程序内部有几个 Struts 2 命名空间和 Struts 1 模块。例如:

/public (Struts 1 module)
/accounting (Struts 2 namespace)
/auditing (Struts 2 namespace)
/receipts (Struts 1 modules)

在我的 web.xml 中,Struts 1 和 2 过滤器专门映射到正确的命名空间/模块。例如,

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/accounting/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>struts1</filter-name>
    <url-pattern>/public/*</url-pattern>
</filter-mapping>

在我的 Struts 1 区域内,我请求将 Struts 1 动作转发到 Struts 2 动作。我尝试了以下方法:

<action path="/myRedirect" forward="/checkAccountRecords.action" module="accounting" />

但是,这会导致以下堆栈跟踪:

The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

我知道这可以通过通过 Struts 2 过滤器映射网站的 Struts 1 部分来解决,但这会给我们的特定网站带来问题,我想避免这样做。

我还尝试了没有模块的操作:

<action path="/myRedirect" forward="/accounting/checkAccountRecords.action" />

我收到以下错误:

can't find /receipts/accounting/checkAccountRecords.action (file not found)

我还尝试了以下动作映射:

<action path="/myRedirect" forward="../accounting/checkAccountRecords.action" />

我收到以下错误:

Path ../accounting/checkAccountRecords.action does not start with a "/" character

那么还有什么我可以尝试的吗?如何获得 Struts 1 操作以将重定向返回到 Struts 2 操作?

4

1 回答 1

1

作为一种解决方法,在我的Struts操作中,我手动修改了response.sendRedirect将用户发送到正确的页面,而不是将其映射到struts.xml文件中。

于 2012-05-16T15:57:53.303 回答