首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Struts 1操作重定向到Struts 2操作

Struts 1操作重定向到Struts 2操作
EN

Stack Overflow用户
提问于 2012-05-15 23:02:03
回答 1查看 2.1K关注 0票数 1

我有一个同时有struts 1和struts 2的java webapp,里面有几个Struts2命名空间和Struts1模块。例如:

代码语言:javascript
复制
/public (Struts 1 module)
/accounting (Struts 2 namespace)
/auditing (Struts 2 namespace)
/receipts (Struts 1 modules)

在我的web.xml中,Struts1和Struts2过滤器被明确映射到正确的名称空间/模块。例如,

代码语言:javascript
复制
<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>

在我的Struts1区域中,我有一个让Struts1动作转发到Struts2动作的请求。我尝试了以下几种方法:

代码语言:javascript
复制
<action path="/myRedirect" forward="/checkAccountRecords.action" module="accounting" />

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

代码语言:javascript
复制
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]

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

我还尝试了不使用该模块的操作:

代码语言:javascript
复制
<action path="/myRedirect" forward="/accounting/checkAccountRecords.action" />

我得到了下面的错误:

代码语言:javascript
复制
can't find /receipts/accounting/checkAccountRecords.action (file not found)

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

代码语言:javascript
复制
<action path="/myRedirect" forward="../accounting/checkAccountRecords.action" />

我得到了以下错误:

代码语言:javascript
复制
Path ../accounting/checkAccountRecords.action does not start with a "/" character

那么还有什么我可以试一下的吗?如何让Struts1操作返回到Struts2操作的重定向?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-16 23:57:53

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10603538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档