struts2結果型別

2021-07-28 17:55:52 字數 1295 閱讀 8943

在struts2-core-2.3.1.1.jar/struts-de****t.xml配置檔案下可以看到:

..........省略

chain:兩個action之間的**

dispatcher:action**到jsp

freemarker:處理freemarker用的

httpheader:處理特殊http

redirect:action重定向到jsp

stream:以inputstream流的方式傳送到瀏覽器

velocity:處理velocity模板

xslt:處理xml模板

plainttext:以源**的形式展示給瀏覽器

對於**以及跳轉到jsp檢視的結果型別:

/index.jsp

對於**以及跳轉到action的結果型別,可以指定三個引數:命名空間,action,方法

除了action引數,命名空間預設是"/",方法預設是action中指定的method引數.

torequest

tomethod

對於plaintext方式,需要指定兩個引數:

/index.jsp

gbk

對於stream方式,指定流的內容型別,以及流的獲取源.

image/jpeg

imagestream

attachment;filename=$

$會讀取action中的filename例項變數.

在struts.xml配置檔案中,一般存在於內,此時的result是在當前action中有效,對其他action無效的,若想要實現乙個對所有action都有效的result,可以在action外宣告乙個全域性的result結果:

/index.jsp

注意:全域性結果型別要寫在***宣告下面,上面,就比如這樣:

/index.jsp

/result.jsp

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的結果型別...

struts2結果型別

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