Chain Result:
這個result調(diào)用另外的一個action,連接自己的攔截器棧和result。
- actionName (默認(rèn)) - 被調(diào)用的action的名字
- namespace - 被調(diào)用的action的名稱空間. 如果名稱空間為空,這默認(rèn)為當(dāng)前名稱空間
- method - 用于指定目標(biāo)action的另一個方法被調(diào)用. 如果空,默認(rèn)為excute方法
Redirect Action Result:這個Result使用ActionMapperFactory提供的ActionMapper來重定位瀏覽器的URL來調(diào)用指定的action和(可選的)namespace. 這個Result比ServletRedirectResult要好.因?yàn)槟悴恍枰裊RL編碼成xwork.xml中配置的ActionMapper提供的模式. 這就是說你可以在任意點(diǎn)上改變URL模式而不會影響你的應(yīng)用程序. 因此強(qiáng)烈推薦使用這個Result而不是標(biāo)準(zhǔn)的redirect result來解決重定位到某個action的情況.
- ActionName (默認(rèn)) - 重定位到的action名
- namespace - action的名稱空間. 如果為null,則為當(dāng)前名稱空間
Redirect Result調(diào)用{@link HttpServletResponse#sendRedirect(String) sendRedirect}方法來轉(zhuǎn)到指定的位置. HTTP響應(yīng)被告知使瀏覽器直接跳轉(zhuǎn)到指定的位置(產(chǎn)生客戶端的一個新請求). 這樣做的結(jié)果會使剛剛執(zhí)行的action(包括action實(shí)例,action中的錯誤消息等)丟失, 不再可用. 這是因?yàn)閍ction是建立在單線程模型基礎(chǔ)上的. 傳遞數(shù)據(jù)的唯一方式就是通過Session或者可以為Ognl表達(dá)式的web參數(shù)(url?name=value)
- location (默認(rèn)) - action執(zhí)行后跳轉(zhuǎn)的地址.
- parse - 默認(rèn)為true. 如果設(shè)置為false, location參數(shù)不會被當(dāng)作Ognl表達(dá)式解析.
<result name="success" type="redirect">/displayCart.action?userId=${userId}</result>
------------
Chain result type is used for Action Chaining which means that the source result invokes an entire other action, complete with it's own interceptor stack and result.
Redirect Action result type is used to redirect to another Action which means making your source Action, after it has successfully executed, result in a redirect.
As a rule, Action Chaining is not recommended. Redirect Result or the Redirect Action Result is preferred over Chain Result.