struts2 action 之間的跳轉

2022-04-09 13:46:17 字數 2490 閱讀 7990

從action1直接跳轉到action2,有兩種方法: 

1. 需要儲存前乙個action的屬性資訊時使用,儲存住action1的request物件: 

action2  此處 action2 指action名稱,無須帶.action 或者.do

2. 不儲存前乙個action的引數可以用這種方法: 

action2 這個就需要 帶上.action 名稱

<?

xml version="1.0" encoding="utf-8"

?>

doctype struts public "-//apache software foundation//dtd struts configuration 2.1//en" ""

>

<

struts

>

<

package

name

="chemical"

namespace

="/chemical"

extends

="global"

>

<

action

name

="*"

class

="com.sinocarbon.tbl.action.chemicalaction"

method

="">

<

result

name

="addrawmaterial"

>/entp_pages/chemical/rawmaterial.jsp

result

>

<

result

name

="toeditrawmaterial"

type

="chain"

>toeditrawmaterial

result

>

<

result

name

="addcarbonate"

>/entp_pages/chemical/carbonate.jsp

result

>

<

result

name

="toeditcarbonate"

type

="chain"

>toeditcarbonate

result

>

<

result

name

="addnitricacid"

>/entp_pages/chemical/nitricacid.jsp

result

>

<

result

name

="toeditnitricacid"

type

="chain"

>toeditnitricacid

result

>

<

result

name

="addadipicacid"

>/entp_pages/chemical/adipicacid.jsp

result

>

<

result

name

="toeditadipicacid"

type

="chain"

>toeditadipicacid

result

>

<

result

name

="addsupplyco2"

>/entp_pages/chemical/supplyco2.jsp

result

>

<

result

name

="toeditsupplyco2"

type

="chain"

>toeditsupplyco2

result

>

<

result

name

="editrawmaterial"

>/entp_pages/chemical/editrawmaterial.jsp

result

>

<

result

name

="editcarbonate"

>/entp_pages/chemical/editcarbonate.jsp

result

>

<

result

name

="editnitricacid"

>/entp_pages/chemical/editnitricacid.jsp

result

>

action

>

package

>

struts

>

struts2 action之間的跳轉

result的name屬性 success action正確的執行完成,返回相應的檢視,success是name屬性的預設值 none 表示action正確的執行完成,但並不返回任何檢視 error 表示action執行失敗,返回到錯誤處理檢視 input action的執行,需要從前端介面獲取引數...

struts2 action 配置方法

struts2 action幾乎完全吸收了xwork 的精華,近日學習struts 2,總結一下action的配製方法。首先看一下com.opensymphony.xwork2.action的介面宣告,action提供execute 方法,子類必須實現execute 方法。public inte c...

struts2 action中result引數詳解

chain 用來處理action鏈 com.opensymphony.xwork2.actionchainresult dispatcher 用來轉向頁面,通常處理jsp org.apache.struts2.dispatcher.servletdispatcherresult freemaker ...