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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

Struts2中五个重要的常量

發布時間:2025/7/14 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Struts2中五个重要的常量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一.五個常量的位置:位于xwork核心包下的Action字節碼文件里

? ? ? ? ? ? ? ? ? ? ? ? ? ?

二.五個常量的介紹:

a: SUCCESS

1 public static final String SUCCESS = "success";

 ? ?   英文注釋: The action execution was successful. Show result??view to the end user.? ? ? action執行成功,會返回一個結果視圖給用戶? 。

?  具體用法:

1.action類中:

1 public String execute() throws Exception { 2 return SUCCESS; 3 }

struts.xml文件:result標簽默認就是success,所以可以省略,這里面默認的name="success",底層會自動幫你找尋返回值為success,并為其跳轉到對應的視圖界面

<result type="redirect">item.jsp</result>

  

b:? NONE

public static final String NONE = "none";

  英文解釋:The action execution was successful but do not?show a view. This is useful for actions that are?handling the view in another fashion like redirect.??

?  action執行是成功的,但是不會顯示界面(視圖),這對于以另一種重定向方式處理視圖是有用的。簡單說就是不讓跳轉到其他界面

具體用法:

public String execute() throws Exception {return NONE; }

?

c:? ?ERROR?

public static final String ERROR = "error";

  英文解釋:The action execution was a failure.Show an error view, possibly asking the?user to retry entering data.

  action執行失敗了,跳轉顯示一個錯誤視圖,可能請求用戶再次輸入相關數據。也就是說,當anction返回結果fail或者其他失敗,會幫你跳轉到錯誤信息對于的視圖

具體用法:

//action類:
public
String execute() throws Exception {//條件代碼return ERROR; }

//struts.xml
<result name="error" type="redirect">item.jsp</result>

?

d: LOGIN

public static final String LOGIN = "login";

  英文解釋:The action could not execute, since the?user most was not logged in. The login view?should be shown.

  這個anction不能執行,由于用戶沒有登錄 ,該登錄視圖可能會被顯示。也就是說登錄出錯頁面跳轉

? ? ?

//action類: public String execute() throws Exception {//條件代碼return LOGIN; }//struts.xml <result name="login" type="redirect">login.jsp</result>

?

? e:? ?INPUT ***

public static final String LOGIN = "input";

  英文:The action execution require more input?in order to succeed.This result is typically used if a form?handling action has been executed so as?to provide defaults for a form. Theform associated with the handler should beshown to the end user.<p/>This result is also used if the given input?params are invalid, meaning the user??should try providing input again.

這個action為了成功需要多次輸入,如果一個表單表單處理action操作被執行,便會為表單提供默認表單,通常會使用此結果。這個表單會顯示給最終用戶,這個結果也被用來用戶輸入無效,這意味著用戶需要在輸入一遍

?

上面五個變量其中除了input,其他都可以使用自定義的,只有input不能改,input視圖在某些攔截器中使用,如數據校驗,類型轉化等等都可能出現錯誤,這些錯誤在struts2中專門放在數據存儲區域的錯誤信息區域,struts2再走到最后一個workflow攔截器種會檢查錯誤區域是否有錯誤信息,如果有,跳轉到input視圖。

?

上面就是簡單的描述。

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?

轉載于:https://www.cnblogs.com/ends-earth/p/10701772.html

總結

以上是生活随笔為你收集整理的Struts2中五个重要的常量的全部內容,希望文章能夠幫你解決所遇到的問題。

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