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

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 小果子 閱讀(548) 評論(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>
            亚洲综合999| 欧美成人免费在线观看| 亚洲人成在线播放| 美日韩精品免费| 亚洲人成绝费网站色www| 欧美激情国产日韩| 欧美777四色影视在线| 亚洲精品免费在线| 亚洲免费成人av电影| 国产精品老牛| 久久久国产成人精品| 久久久久一区二区三区四区| 亚洲福利视频网站| 亚洲精选中文字幕| 国产精品亚洲网站| 亚洲男女毛片无遮挡| 欧美怡红院视频| 亚洲高清不卡在线| 日韩手机在线导航| 国产视频久久| 亚洲国产欧美在线人成| 欧美午夜一区| 免费成人高清视频| 欧美日韩国产区一| 久久久国产精品一区| 欧美jizz19性欧美| 亚洲欧美韩国| 女人天堂亚洲aⅴ在线观看| 亚洲一区二区高清| 久久精品国产精品亚洲综合 | 午夜视频久久久久久| 国产一区二区在线观看免费| 欧美高清成人| 国产日韩成人精品| 亚洲黄色成人久久久| 国产老女人精品毛片久久| 欧美a级片一区| 欧美性猛交99久久久久99按摩| 久久成人一区| 欧美激情一区二区三区不卡| 欧美综合激情网| 欧美女同在线视频| 美女久久一区| 国产欧美精品一区二区色综合| 欧美激情亚洲一区| 国产一区二区三区精品欧美日韩一区二区三区 | 亚洲精品一区中文| 1024日韩| 欧美在线www| 亚洲欧美精品一区| 欧美激情一区二区三区在线视频| 久久国产精品一区二区三区| 欧美美女喷水视频| 亚洲成人在线网站| 狠狠色狠狠色综合日日五| 一区二区三区 在线观看视| 亚洲激情在线播放| 久久精品亚洲| 久久色中文字幕| 国产欧美午夜| 亚洲综合电影| 亚洲欧美日韩一区在线| 欧美黄色小视频| 久久综合久久88| 国产一区亚洲一区| 欧美一级欧美一级在线播放| 亚洲欧美日本国产专区一区| 欧美日韩综合视频| 99www免费人成精品| 一本大道久久精品懂色aⅴ| 欧美成人亚洲成人| 欧美激情视频在线免费观看 欧美视频免费一 | 美女视频网站黄色亚洲| 免费欧美在线| 激情综合在线| 免费中文日韩| 亚洲人成人77777线观看| 亚洲精品久久久久久一区二区 | 性视频1819p久久| 免费欧美日韩| 亚洲电影免费在线观看| 亚洲欧洲综合| 欧美日韩国语| 亚洲一区二区三区三| 欧美一区二区三区四区在线| 国产一区 二区 三区一级| 欧美在线高清| 欧美国产先锋| 亚洲天堂av综合网| 国产伦理一区| 免费短视频成人日韩| 亚洲人成网站在线播| 制服丝袜激情欧洲亚洲| 国产精品黄色| 欧美中在线观看| 欧美激情一区二区三区成人 | 国产精品久久久久婷婷| 亚洲欧美日韩成人| 男男成人高潮片免费网站| 亚洲美女淫视频| 国产精品亚洲视频| 裸体歌舞表演一区二区| 91久久精品www人人做人人爽| 中日韩美女免费视频网站在线观看| 国产精品家庭影院| 久久蜜臀精品av| 日韩视频一区二区| 久久久午夜视频| 中日韩在线视频| 国自产拍偷拍福利精品免费一| 久久一区中文字幕| 一区二区成人精品| 久久综合久色欧美综合狠狠| 妖精成人www高清在线观看| 国产午夜精品理论片a级大结局| 久久亚洲综合| 亚洲永久免费| 亚洲国产精品女人久久久| 亚洲欧美色一区| 亚洲精品国精品久久99热| 国产人久久人人人人爽| 欧美成人亚洲成人日韩成人| 欧美一区二区免费观在线| 亚洲美女精品久久| 欧美成人综合| 久久人人超碰| 久久精品一区二区三区中文字幕| 一区二区免费在线视频| 最新中文字幕亚洲| 在线观看欧美| 国产综合av| 国产日韩亚洲| 国产麻豆精品视频| 欧美涩涩视频| 欧美日韩视频在线第一区| 免播放器亚洲| 久久女同精品一区二区| 午夜激情综合网| 亚洲网站在线观看| 日韩视频免费观看高清完整版| 欧美jizzhd精品欧美巨大免费| 久久久国产一区二区| 欧美在线影院在线视频| 午夜综合激情| 亚洲欧美第一页| 亚洲淫性视频| 亚洲欧美成人精品| 亚洲伊人观看| 亚洲综合三区| 午夜精彩国产免费不卡不顿大片| 亚洲视频在线观看| 亚洲一卡二卡三卡四卡五卡| 亚洲少妇自拍| 亚洲欧美日韩国产成人| 亚洲欧美一区二区精品久久久| 亚洲夜晚福利在线观看| 亚洲一区二区精品在线| 亚洲视频欧美在线| 亚洲一区二区三区四区在线观看| 亚洲无毛电影| 亚洲性xxxx| 欧美一区二区高清| 久久理论片午夜琪琪电影网| 久久蜜桃av一区精品变态类天堂| 久久久水蜜桃av免费网站| 久久综合伊人77777蜜臀| 欧美成人免费全部观看天天性色| 欧美大尺度在线观看| 最新亚洲视频| 亚洲欧美激情四射在线日| 亚洲欧美在线磁力| 久久久国产亚洲精品| 模特精品在线| 欧美日韩中文字幕在线视频| 国产九九精品| 亚洲国产高清在线观看视频| 99国产精品久久久久久久久久 | 国产亚洲制服色| 亚洲国产日韩一区| 一区二区三区福利| 久久久久**毛片大全| 亚洲国产高清视频| 亚洲影院高清在线| 久久久久久久国产| 欧美日韩一区二区三区视频| 国产一区自拍视频| 99re6热只有精品免费观看 | 一区二区欧美亚洲| 久久国产精品电影| 亚洲人妖在线| 欧美一区影院| 欧美日韩日本国产亚洲在线| 狠狠色丁香久久婷婷综合_中| 中日韩美女免费视频网站在线观看| 久久国产精品毛片| 99国产精品| 免费日本视频一区| 国产一区观看| 亚洲一区三区视频在线观看| 欧美成人精品高清在线播放|