struts配置檔案中結果型別小結

2021-07-15 12:50:28 字數 604 閱讀 2356

result配置類似於struts1中的forward,但struts2中提供了多種結果型別,常用的型別有:

dispatcher(預設值)、chain、 redirect 、 redirectaction 、 plaintext。

注:在struts2中重定向可能導致資料丟失,**不會

method="test">

/test02/test.action

method="testdispatch">

dispatcher

下面是redirect 結果型別的例子,如果重定向的action中同乙個包下: 

helloworld

如果重定向的action在別的命名空間下:

/test/helloworld

下面是redirectaction 結果型別的例子,如果重定向的action中同乙個包下: 

helloworld

如果重定向的action在別的命名空間下:

helloworld

/test

plaintext:顯示原始檔案內容,例如:當我們需要原樣顯示jsp檔案源** 的時候,我們可以使用此型別。

/***.jsp

utf-8

struts2結果型別

在struts2 core 2.3.1.1.jar struts de t.xml配置檔案下可以看到 省略 chain 兩個action之間的 dispatcher action 到jsp freemarker 處理freemarker用的 httpheader 處理特殊http redirect ...

Struts2結果型別

struts2結果型別 1.dispatcher 將當前請求request和response移交給另乙個servlet,預設型別 2.redirect 重定向 關閉當前請求,改變瀏覽器指向的url,不移交request和response secure adminportfolio.action 末尾...

struts2結果型別

struts2結果型別 結果型別 描述 前request域屬性是否丟失 1dispatcher 用於與jsp整合的結果型別。預設結果型別。2chain action鏈式處理結果型別。前乙個action設定的request域屬性不丟失。不丟失3 redirect 用於直接跳轉到其他頁面url的結果型別...