Struts2配置RESULT中TYPE的引數說明

2021-06-25 15:54:45 字數 2350 閱讀 7865



chain   

用來處理action鏈,被跳轉的action中仍能獲取上個頁面的值,如request資訊。   

com.opensymphony.xwork2.actionchainresult   

dispatcher   

用來轉向頁面,通常處理jsp   

org.apache.struts2.dispatcher.servletdispatcherresult   

freemaker   

處理freemarker模板   

控制特殊http行為的結果型別   

重定向到乙個url ,被跳轉的頁面中丟失傳遞的資訊,如request  

org.apache.struts2.dispatcher.servletredirectresult   

redirectaction   

重定向到乙個action ,跳轉的頁面中丟失傳遞的資訊,如request     

org.apache.struts2.dispatcher.servletactionredirectresult   

redirect-action   

重定向到乙個action ,跳轉的頁面中丟失傳遞的資訊,如request     

org.apache.struts2.dispatcher.servletactionredirectresult

注:redirect與redirect-action區別

一、使用redirect需要字尾名 使用redirect-action不需要字尾名

二、type="redirect" 的值可以轉到其它命名空間下的action,而redirect-action只能轉到同一命名空下的 action,因此它可以省略.action的字尾直接寫action的名稱。

如:

viewtask.action

viewtask

附:redirect-action 傳遞引數

showpreinfo?preinfo.order_number=$&preinfo.company_name=$   

/error.jsp

因為使用了redirect-action,所以要注意不能將 showpreinf?preinfo.order_number=$寫成 showpreinf.action?preinfo.order_number=$

其中${}為el表示式,獲取action:enterpreinfo中屬性的值;在這個配置檔案裡,多個引數的連線符使用了"&",但xml的語法規範,應該使用"&"代替"&",原理和html中的轉義相同,開始沒有注意,在struts分析配置檔案時,總是報出這樣的錯誤:

json   一般很容易忽略的乙個地方(在ext中非常有用)示例view plaincopy to clipboardprint?success,result

/index.jsp

success,result

/index.jsp

view plaincopy to clipboardprint?private boolean success  = true;   private string result = "main.action";   //getter和setter方法略  private boolean success  = true;

private string result = "main.action";

//getter和setter方法略

以上的success和result互相對應到了view plaincopy to clipboardprint?success,result

success,result  struts2會根據其設定的值匹配跳轉對於json一般情況下很少用到,但是在處理ext的時候會用到這個屬性型別,這個地方也是經常被忽略的。

Struts2配置RESULT中TYPE的引數說明

chain 用來處理action鏈,被跳轉的action中仍能獲取上個頁面的值,如request資訊。com.opensymphony.xwork2.actionchainresult dispatcher 用來轉向頁面,通常處理jsp org.apache.struts2.dispatcher.s...

Struts2配置RESULT中TYPE的引數說明

chain 用來處理action鏈,被跳轉的action中仍能獲取上個頁面的值,如request資訊。com.opensymphony.xwork2.actionchainresult dispatcher 用來轉向頁面,通常處理jsp org.apache.struts2.dispatcher.s...

Struts2配置RESULT中TYPE的引數說明

chain 用來處理action鏈,被跳轉的action中仍能獲取上個頁面的值,如request資訊。com.opensymphony.xwork2.actionchainresult dispatcher 用來轉向頁面,通常處理jsp org.apache.struts2.dispatcher.s...