简体   繁体   中英

Problems in migrating Struts 2.3 to 2.5

I'm trying migrate from Struts 2.3 to 2.5.2 but I have two weird problems. They were good in 2.3 so maybe the problem is about Convention plugin.

Let's assume I have two actions:

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

In 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

In 2.5:

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

And if I set in default action in struts.xml:

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

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

Then

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

It seems that if I have default action then every action in main package (mypackage.actions) is hidden by OtherAction but

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

Is it a bug in Struts 2.5.2? How can set default action without making actions in main package wrong? How can I fix not to access actions in main package with anyurl/*.action

Both problems are fixed by setting "/" namespace in every action in the main package:

@Namespace("/")

When request url is

/anything/limit.action 

and Struts can't find the action, it will look after LimitAction in the default "" namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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