繁体   English   中英

Struts 2.3 到 2.5 迁移的问题

[英]Problems in migrating Struts 2.3 to 2.5

我正在尝试从 Struts 2.3 迁移到 2.5.2,但我有两个奇怪的问题。 它们在 2.3 中很好,所以问题可能出在公约插件上。

假设我有两个动作:

mypackage.actions.LimitAction
mypackage.actions.user.UserAction

在 2.3 中:

http://myurl/limit.action          -> OK
http://myurl/anything/limit.action -> There is no Action ... which is OK
http://myurl/user/user.action      -> OK

在 2.5 中:

http://myurl/anything/limit.action -> OK ... which should be There is no Action ...

如果我在 struts.xml 中设置默认操作:

<default-action-ref name="other" />

<action name="other" class="mypackage.actions.OtherAction">
    <result />
</action>

然后

http://myurl/limit.action          -> went wrong and OtherAction is shown

似乎如果我有默认操作,那么主包(mypackage.actions)中的每个操作都被 OtherAction 隐藏,但是

http://myurl/anything/limit.action -> still works which is wrong too

它是 Struts 2.5.2 中的错误吗? 如何在不使主包中的操作出错的情况下设置默认操作? 如何修复不使用 anyurl/*.action 访问主包中的操作

通过在主包中的每个操作中设置"/"命名空间来解决这两个问题:

@Namespace("/")

当请求 url 是

/anything/limit.action 

并且Struts 找不到动作,它会在默认的""命名空间中查找LimitAction。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM