迁移Struts 2.3到2.5的问题

时间:2016-09-19 08:05:29

标签: java http configuration struts2 struts-action

我正在尝试从Struts 2.3迁移到2.5.2,但我有两个奇怪的问题。他们在2.3中很好,所以问题可能是关于Convention插件。

我们假设我有两个动作:

(... indexOf(nadaValue.toString()) ... )

在2.3:

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

在2.5:

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

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

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

然后

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

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

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

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

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

访问主程序包中的操作

1 个答案:

答案 0 :(得分:1)

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

@Namespace("/")

请求网址

/anything/limit.action 

并且Struts无法找到该操作,它将在默认的""命名空间中处理LimitAction。