日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Struts2中五个重要的常量

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

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

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

二.五個常量的介紹:

a: SUCCESS

1 public static final String SUCCESS = "success";

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

?  具體用法:

1.action類中:

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

struts.xml文件:result標簽?zāi)J就是success,所以可以省略,這里面默認的name="success",底層會自動幫你找尋返回值為success,并為其跳轉(zhuǎn)到對應(yīng)的視圖界面

<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執(zhí)行是成功的,但是不會顯示界面(視圖),這對于以另一種重定向方式處理視圖是有用的。簡單說就是不讓跳轉(zhuǎn)到其他界面

具體用法:

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執(zhí)行失敗了,跳轉(zhuǎn)顯示一個錯誤視圖,可能請求用戶再次輸入相關(guān)數(shù)據(jù)。也就是說,當anction返回結(jié)果fail或者其他失敗,會幫你跳轉(zhuǎn)到錯誤信息對于的視圖

具體用法:

//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不能執(zhí)行,由于用戶沒有登錄 ,該登錄視圖可能會被顯示。也就是說登錄出錯頁面跳轉(zhuǎn)

? ? ?

//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操作被執(zhí)行,便會為表單提供默認表單,通常會使用此結(jié)果。這個表單會顯示給最終用戶,這個結(jié)果也被用來用戶輸入無效,這意味著用戶需要在輸入一遍

?

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

?

上面就是簡單的描述。

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

?

轉(zhuǎn)載于:https://www.cnblogs.com/ends-earth/p/10701772.html

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。