Struts2支援的處理結果型別

2022-05-09 01:03:07 字數 2772 閱讀 3747

struts2支援使用多種檢視技術,例如jsp、velocity和freemarker等。當乙個action處理使用者請求結束後,僅僅返回乙個字串,這個字串就是邏輯檢視名,但改邏輯檢視並未與任何的檢視技術及任何的資源關聯--直到我們在struts.xml檔案中配置改邏輯檢視。

結果型別決定了action處理結束後,下一步將執行那種型別的動作。

struts2的結果型別要求實現com.opensymphony.xwork.result,這個結果是所有action執行結果的通用介面。如果我們需要自己的結果型別,我們應該提供乙個實現改介面的類,並在struts.xml檔案中配置改結果型別。

struts2預設提供了一系列的結果型別,下面是struts-default.xml配置檔案的配置片段:

在struts2-jasperreports-plugin-2.0.6.jar的struts-plugin.xml檔案中的配置片段:

<

result-types

>

<

result-type

name

="jasper"

class

="org.apache.struts2.views.jasperreports.jasperreportsresult"

/>

result-types

>

在struts-jfreechart-plugin-2.0.6.jar的struts-plugin.xml檔案中的配置片段:

<

result-types

>

<

result-type

name

="jsf"

class

="org.apache.struts2.jsf.facesresult"

/>

result-types

>

<

result-types

>

<

result-type

name

="tiles"

class

="org.apache.struts2.views.tiles.tilesresult"

/>

result-types

>

struts2 支援的結果型別

在中的type配置 預設是dispatcher對應jsp頁面 chain action鏈式處理的結果型別 freemarker 指定使用freemarker膜拜作為結果 的結果型別 httpheader 用於控制特殊的http行為的結果型別 redirect 用於直接跳轉到其他url的結果型別 re...

struts2支援的結果處理型別

有些東西常常在用,自己卻忽略總結,這是乙個特別的失誤.struts2支援的結果處理型別 struts2的結果處理型別要在struts default.xml檔案中的中搜尋其支援的結果型別 歸納起來,struts2內建支援的結果型別如下 chain action鏈式處理結果型別 dispatcher ...

struts2 處理結果型別

struts2的處理流程 使用者請求 struts2框架 控制器 struts2框架 檢視資源 success.jsp當result中的name值預設為success。input action的執行需要前端獲得引數,input代表這個引數傳遞的頁面,對一些引數進行驗證,驗證不通過時,返回input頁...