簡體   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