青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

xiaoguozi's Blog
Pay it forword - 我并不覺的自豪,我所嘗試的事情都失敗了······習慣原本生活的人不容易改變,就算現狀很糟,他們也很難改變,在過程中,他們還是放棄了······他們一放棄,大家就都是輸家······讓愛傳出去,很困難,也無法預料,人們需要更細心的觀察別人,要隨時注意才能保護別人,因為他們未必知道自己要什么·····
提交服務器處理業務后結果返回頁面的處理,Struts2提供了對不同種類返回結果的支持,常見的有JSP,FreeMarker,Velocity等。

struts.xml配置文件中result的語法:<result name="" type="">xxxxx</result>

Struts2支持的不同類型的返回結果為:

Chain Result-->type="chain"
用來處理Action鏈

Dispatcher Result -->type="dispatcher"
用來轉向頁面,通常處理JSP

FreeMarker Result -->type="freemarker"
處理FreeMarker模板

HttpHeader Result -->type="httpheader"
用來控制特殊的Http行為

Redirect Result -->type="redirect"
重定向到一個URL

Redirect Action Result -->type="redirectAction"
重定向到一個Action

Stream Result -->type="stream"
向瀏覽器發送InputSream對象,通常用來處理文件下載

Velocity Result -->type="velocity"
處理Velocity模板

XLST Result -->type="xslt"
處理XML/XLST模板

PlainText Result -->type="plainText"
顯示原始文件內容,例如文件源代碼


另外第三方的result類型還包括JasperReports Plugin,專門用來處理JasperReport類型的報表輸出。

在struts-default.xml文件中已經有了對于所有類型Result的定義:

Java 代碼

1. <result-types>  
2.  
3.     <result-type name="chain"  
4.  
5.              class="com.opensymphony.xwork2.ActionChainResult"/>  
6.  
7.     <result-type name="dispatcher"  
8.  
9.              class="org.apache.struts2.dispatcher.ServletDispatcherResult"  
10.  
11.              default="true"/>  
12.  
13.     <result-type name="freemarker"  
14.  
15.              class="org.apache.struts2.views.freemarker.FreemarkerResult"/>  
16.  
17.     <result-type name="httpheader"  
18.  
19.              class="org.apache.struts2.dispatcher.HttpHeaderResult"/>  
20.  
21.     <result-type name="redirect"  
22.  
23.              class="org.apache.struts2.dispatcher.ServletRedirectResult"/>  
24.  
25.     <result-type name="redirectAction"  
26.  
27.              class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>  
28.  
29.     <result-type name="stream"  
30.  
31.              class="org.apache.struts2.dispatcher.StreamResult"/>  
32.  
33.     <result-type name="velocity"  
34.  
35.              class="org.apache.struts2.dispatcher.VelocityResult"/>  
36.  
37.     <result-type name="xslt"  
38.  
39.              class="org.apache.struts2.views.xslt.XSLTResult"/>  
40.  
41.     <result-type name="plainText"  
42.  
43.              class="org.apache.struts2.dispatcher.PlainTextResult" />  
44.  
45.     <!-- Deprecated name form scheduled for removal in Struts 2.1.0.  
46.  
47.          The camelCase versions are preferred. See ww-1707 -->  
48.  
49.     <result-type name="redirect-action"  
50.  
51.              class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>  
52.  
53.     <result-type name="plaintext"  
54.  
55.              class="org.apache.struts2.dispatcher.PlainTextResult" />  
56.  
57. </result-types>  

<result-types>

<result-type name="chain"

class="com.opensymphony.xwork2.ActionChainResult"/>

<result-type name="dispatcher"

class="org.apache.struts2.dispatcher.ServletDispatcherResult"

default="true"/>

<result-type name="freemarker"

class="org.apache.struts2.views.freemarker.FreemarkerResult"/>

<result-type name="httpheader"

class="org.apache.struts2.dispatcher.HttpHeaderResult"/>

<result-type name="redirect"

class="org.apache.struts2.dispatcher.ServletRedirectResult"/>

<result-type name="redirectAction"

class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

<result-type name="stream"

class="org.apache.struts2.dispatcher.StreamResult"/>

<result-type name="velocity"

class="org.apache.struts2.dispatcher.VelocityResult"/>

<result-type name="xslt"

class="org.apache.struts2.views.xslt.XSLTResult"/>

<result-type name="plainText"

class="org.apache.struts2.dispatcher.PlainTextResult" />

<!-- Deprecated name form scheduled for removal in Struts 2.1.0.

The camelCase versions are preferred. See ww-1707 -->

<result-type name="redirect-action"

class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

<result-type name="plaintext"

class="org.apache.struts2.dispatcher.PlainTextResult" />

</result-types>



從上述代碼中可以看出在不指定Result類型的時候默認使用dispatcher類型。


定義一個Result值,

Java 代碼

1. <result name="success" type="dispatcher">  
2.  
3.     <param name="location">/myjsp.jsp</param>  
4.  
5. </result>  

<result name="success" type="dispatcher">

<param name="location">/myjsp.jsp</param>

</result>


由于type默認值是dispatcher,所以這里不需要定義,另外name的默認值為success所以這里也不需要定義。
上述代碼可以簡寫為:

Java 代碼

1. <result>  
2.  
3.     <param name="location">/myjsp.jsp</param>  
4.  
5. </result>  

<result>

<param name="location">/myjsp.jsp</param>

</result>




另外location參數也可以直接卸載result標簽內部(也就是無需再result里面使用),所以上述代碼的最簡單的寫法為:

Java 代碼

1. <result>/myjsp.jsp</result>  

<result>/myjsp.jsp</result>



我們也可以定義多個不同的result

Java 代碼

1. <action name="Hello">  
2.  
3. <result>/hello/hello.jsp</result>  
4.  
5. <result name="error">/hello/error.jsp</result>  
6.  
7. <result name="input">/hello/input.jsp</result>  
8.  
9. </action>  

<action name="Hello">

<result>/hello/hello.jsp</result>

<result name="error">/hello/error.jsp</result>

<result name="input">/hello/input.jsp</result>

</action>



上 述代碼的含義為,名字為Hello的Action有三個返回結果,并且都是 dispatcher類型(默認類型),這三個返回值的名字分別為success(默認值),error,input(當輸入不通過時,action 方法返回input),對應的頁面的路徑分別為 /hello/result.jsp,/hello/error.jsp,/hello/input.jsp。

有些時候我們需要一個定義在全局的result,這個時候我們可以在package內部定義全局的result,例如:

Java 代碼

1. <global-results>  
2.  
3. <result name="error">/error.jsp</result>  
4.  
5. <result name="invalid.token">/error.jsp</result>  
6.  
7. <result name="login" type="redirect-action">login!input</result>  
8.  
9. </global-results>  

<global-results>

<result name="error">/error.jsp</result>

<result name="invalid.token">/error.jsp</result>

<result name="login" type="redirect-action">login!input</result>

</global-results>



動態返回結果

有些時候,只有當Action執行完璧的時候我們才知道要返回哪個結果,這個時候我們可以在Action內部定義一個屬性,這個屬性用來存儲 Action執行完璧之后的Result值,例如:

Java 代碼

1. private String nextAction;  
2.  
3. public String getNextAction() {  
4.  
5.     return nextAction;  
6.  
7. }  

private String nextAction;

public String getNextAction() {

return nextAction;

}



在strutx.xml配置文件中,我們可以使用${nextAction}來引用到Action中的屬性,通過${nextAction}表示的內容來動態的返回結果,例如:

Java 代碼

1. <action name="fragment" class="FragmentAction">  
2.  
3. <result name="next" type="redirect-action">${nextAction}</result>  
4.  
5. </action>  

<action name="fragment" class="FragmentAction">

<result name="next" type="redirect-action">${nextAction}</result>

</action>



上述Action的execute方法返回next的時候,還需要根據nextAction的屬性來判斷具體定位到哪個Action。


在struts.xml配置文件中,我們可以使用method=""來設置調用類的哪個方法,這樣就可以在一個JAVA類中使用不同的方法來實現不同的功能,就無需每個功能寫一類了,例如:
Java 代碼

1. <action name="fragment" class="cn.com.web.FragmentAction" method="add">  
2.       <result>/success.jsp</result>  
3. </action> 
posted on 2011-04-05 18:17 小果子 閱讀(540) 評論(0)  編輯 收藏 引用 所屬分類: 框架
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美成人精品不卡视频在线观看| 国产精品日韩在线播放| 亚洲国产成人av| 免费日韩av| 欧美黄色一级视频| 91久久精品www人人做人人爽| 欧美成人午夜77777| 亚洲第一天堂无码专区| 亚洲精品乱码| 亚洲在线视频观看| 久久久久久久国产| 欧美精品1区2区3区| 国产精品人成在线观看免费| 精品99一区二区| 亚洲精品久久视频| 午夜影院日韩| 欧美国产精品日韩| 中日韩男男gay无套 | 一区二区三区成人| 亚洲欧美成aⅴ人在线观看| 久久九九精品| 欧美三级在线| 在线观看av不卡| 中文网丁香综合网| 玖玖玖免费嫩草在线影院一区| 91久久久久久| 久久久精品动漫| 国产精品扒开腿做爽爽爽软件| 伊人久久婷婷| 欧美一区二区精美| 亚洲精品国产精品乱码不99| 久久精品女人天堂| 国产麻豆午夜三级精品| 亚洲欧洲一区二区在线播放| 亚洲综合电影| 亚洲肉体裸体xxxx137| 欧美一级视频精品观看| 欧美三区免费完整视频在线观看| 黄色日韩网站视频| 欧美日韩综合精品| 国产一区二区精品久久| 夜夜精品视频| 欧美成人a视频| 亚洲欧美日韩综合国产aⅴ| 欧美久久久久久蜜桃| 悠悠资源网久久精品| 欧美一二三区在线观看| 99视频在线观看一区三区| 麻豆精品一区二区综合av| 国内精品久久久久伊人av| 香蕉成人久久| 亚洲五月六月| 国产精品国产| 亚洲欧美美女| 亚洲伊人网站| 国产精品视频最多的网站| 亚洲——在线| 亚洲自拍16p| 国产乱码精品一区二区三区五月婷 | 久久精品卡一| 国产亚洲欧美aaaa| 久久久欧美精品| 久久精品国产亚洲5555| 一区二区三区亚洲| 欧美电影专区| 欧美激情亚洲自拍| 亚洲一区二区三区中文字幕| 亚洲最新视频在线播放| 国产精品国产a级| 欧美中日韩免费视频| 久久精品国产综合| 亚洲国产电影| 夜夜嗨网站十八久久| 国产精品五区| 老司机午夜精品| 欧美国产亚洲精品久久久8v| 亚洲手机在线| 欧美一级片久久久久久久| 樱桃视频在线观看一区| 亚洲大片在线观看| 欧美四级剧情无删版影片| 欧美中文字幕精品| 免费看亚洲片| 午夜久久影院| 老司机免费视频一区二区| 99精品国产一区二区青青牛奶| 一区二区三区久久久| 红桃视频国产精品| 亚洲日本一区二区三区| 国产精品视频免费| 欧美大片免费观看| 国产精品日韩高清| 欧美高清hd18日本| 国产精品一区二区久久| 国产日韩精品一区二区| 欧美国产精品久久| 国产精品一区在线观看你懂的| 乱人伦精品视频在线观看| 欧美日产国产成人免费图片| 久久av在线| 欧美日韩亚洲一区二区三区在线| 久久精品中文| 欧美婷婷久久| 亚洲福利电影| 激情偷拍久久| 亚洲欧美日韩精品久久| 亚洲日本一区二区三区| 香蕉乱码成人久久天堂爱免费| 91久久精品美女高潮| 性欧美激情精品| 亚洲永久免费精品| 欧美日韩大片| 亚洲第一天堂无码专区| 国内精品久久久久影院薰衣草| 日韩亚洲成人av在线| 亚洲黄色高清| 久久九九免费| 久久久99久久精品女同性| 国产精品极品美女粉嫩高清在线 | 你懂的国产精品永久在线| 欧美在线啊v| 国产精品都在这里| 99精品黄色片免费大全| 亚洲精品在线三区| 模特精品裸拍一区| 美女网站久久| 韩国av一区二区三区| 午夜精品久久久久久久99黑人| 亚洲视频高清| 欧美日韩精品欧美日韩精品一| 亚洲国产精品一区二区尤物区| 亚洲国产精品一区二区www在线 | 欧美国产日韩a欧美在线观看| 韩国三级在线一区| 校园春色国产精品| 久久精品国产2020观看福利| 国产精品男gay被猛男狂揉视频| 日韩网站在线观看| 亚洲专区国产精品| 国产精品无码永久免费888| 亚洲专区在线视频| 久久精品在线观看| 尤妮丝一区二区裸体视频| 久久影院亚洲| 亚洲国产日本| 宅男在线国产精品| 国产精品美女www爽爽爽| 亚洲一区二区高清| 久久精品日韩一区二区三区| 激情亚洲网站| 欧美国产视频一区二区| 99这里只有久久精品视频| 亚洲欧美视频| 黄色在线一区| 欧美sm极限捆绑bd| 一本色道久久综合亚洲精品高清| 欧美区亚洲区| 亚洲一区二区三区四区视频| 国产精品福利片| 午夜视频在线观看一区二区三区 | 亚洲人成网站精品片在线观看| 日韩一级免费观看| 国产精品久久久久久久久搜平片 | 久久人人爽人人爽| 亚洲欧洲三级| 欧美一区二区三区四区高清| 樱桃国产成人精品视频| 欧美美女bb生活片| 午夜精品成人在线| 亚洲国产精品悠悠久久琪琪| 亚洲欧美日韩在线| 亚洲福利视频三区| 国产精品人成在线观看免费| 久久精品99无色码中文字幕| 亚洲精品在线免费| 久久亚洲综合| 亚洲欧美一区二区激情| 最近中文字幕mv在线一区二区三区四区| 欧美伦理91i| 久久久天天操| 亚洲欧美变态国产另类| 亚洲激情女人| 久久久精品国产免费观看同学 | 久久久999国产| 亚洲天堂av在线免费| 一区二区视频在线观看| 国产精品第十页| 欧美精品九九| 久久久久青草大香线综合精品| 中文高清一区| 91久久线看在观草草青青| 久久伊人免费视频| 欧美一级片久久久久久久| 一区二区高清在线观看| 亚洲国产一区二区三区在线播| 国色天香一区二区| 国产三区二区一区久久| 国产精品久久久一区麻豆最新章节 | 一区二区三区精密机械公司| 亚洲国产99|