2016-09-19 107 views
2

我試圖從Struts 2.3遷移到2.5.2,但我有兩個奇怪的問題。它們在2.3中很好,所以也許問題是關於Convention插件。將Struts 2.3遷移到2.5的問題

假設我有兩個動作:

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的bug。 2? 如何設置默認動作而不使主包中的動作出錯? 如何解決無法訪問主包操作與anyurl/*動作

回答

1

兩個問題都通過在主包的每一個動作設定"/"命名空間的固定:

@Namespace("/") 

當請求的URL是

/anything/limit.action 

和Struts無法找到該操作,它會在默認的""命名空間中查看LimitAction。