日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Struts2-result类型

發布時間:2025/6/15 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Struts2-result类型 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Struts2 result類型

?

1.dispatcher:服務器跳轉到頁面,通常來處理JSP,默認類型。

?

2.redirect:重定向到頁面。

Action:

1 public String redirect() { 2 message = "message中有值"; 3 return "redirect"; 4 }

struts.xml

1 <package name="chapter3" namespace="/chapter3" extends="struts-default"> 2 <action name="redirectAction" class="chapter3.action.Chapter3Action" method="redirect"> 3 <result name="redirect" type="redirect">/redirect.jsp</result> 4 </action> 5 </package>

注意的地方:外部中轉不能帶值過去,并且頁面不能受保護

傳參數:

1 <action name="redirectAction" class="chapter3.action.Chapter3Action" method="redirect"> 2 <result name="redirect" type="redirect">/redirect.jsp?message=${message}</result> 3 </action>

?頁面:

${param.message}<br>

?

3.chain:服務端跳轉到Action;

action:

1 public String action2() { 2 message = "我是action2中設置的值"; 3 return "action2"; 4 }

?

struts.xml

1 <package name="chapter32" namespace="/chapter32" extends="struts-default"> 2 <action name="action2" class="chapter3.action.Chapter3Action" method="action2"> 3 <result name="action2" type="chain"> 4 <param name="actionName">redirectAction</param> 5 <param name="namespace">/chapter3</param> 6 </result> 7 </action> 8 </package>

?

?

4.redirectAction:外部跳轉到Action;

?

action:

1 public String action3() { 2 message = "我是action3中設置的值"; 3 return "action3"; 4 }

struts.xml

1 <action name="action3" class="chapter3.action.Chapter3Action" method="action3"> 2 <result name="action3" type="redirectAction">redirectAction</result> 3 </action>

?跨命名空間的外部跳轉:

1 public String action4() { 2 message = "我是action4中設置的值"; 3 return "action4"; 4 }

struts.xml

1 <action name="action4" class="chapter3.action.Chapter3Action" method="action4"> 2 <result name="action4" type="redirectAction"> 3 <param name="actionName">redirectAction</param> 4 <param name="namespace">/chapter3</param> 5 </result> 6 </action>

總結

以上是生活随笔為你收集整理的Struts2-result类型的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。