<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我的漫漫程序之旅

    專注于JavaWeb開發(fā)
    隨筆 - 39, 文章 - 310, 評(píng)論 - 411, 引用 - 0
    數(shù)據(jù)加載中……

    Struts2中的Result類型應(yīng)用(action...etc跳轉(zhuǎn))

    概況

    Result類型 是在Action執(zhí)行完,一個(gè)結(jié)果返回后決定發(fā)生什么事的類。開發(fā)者可以自由的根據(jù)他們的應(yīng)用和環(huán)境的需要?jiǎng)?chuàng)建自己的Result類型。例如在WebWork2中,Servlet和Velocity結(jié)果類型已經(jīng)被創(chuàng)建用來顯示web應(yīng)用程序的畫面。

    注意: 所有的webwork內(nèi)建的Result類型都實(shí)現(xiàn)了com.opensymphony.xwork.Result接口. 這個(gè)接口是所有action執(zhí)行結(jié)果的通用接口,不管這個(gè)結(jié)果是用來顯示一個(gè)網(wǎng)頁還是產(chǎn)生一個(gè)email,發(fā)送一個(gè)JMS消息,等.

    Result類型配置中定義了一些類,把它們映射為action配置中可以引用的名字. 也就是為這些類創(chuàng)建便于記憶的鍵-值對(duì).

    snippet of webwork-default.xml
    ...
    
    <result-types>
        
    <result-type name="dispatcher" class="com.opensymphony.webwork.dispatcher.ServletDispatcherResult" default="true"/>
        
    <result-type name="redirect" class="com.opensymphony.webwork.dispatcher.ServletRedirectResult"/>
        
    <result-type name="velocity" class="com.opensymphony.webwork.dispatcher.VelocityResult"/>
        
    <result-type name="chain" class="com.opensymphony.xwork.ActionChainResult"/>
        
    <result-type name="xslt" class="com.opensymphony.webwork.views.xslt.XSLTResult"/>
        
    <result-type name="jasper" class="com.opensymphony.webwork.views.jasperreports.JasperReportsResult"/>
        
    <result-type name="freemarker" class="com.opensymphony.webwork.views.freemarker.FreemarkerResult"/>
        
    <result-type name="httpheader" class="com.opensymphony.webwork.dispatcher.HttpHeaderResult"/>
        
    <result-type name="stream" class="com.opensymphony.webwork.dispatcher.StreamResult"/>
        
    <result-type name="plaintext" class="com.opensymphony.webwork.dispatcher.PlainTextResult" />
    </result-types>
    ...
    snippet of your xwork.xml
    
    
    <include file="webwork-default.xml"/>

    <package name="myPackage" extends="default">
      
    <action name="bar" class="myPackage.barAction">
        
    <!-- default result type is "dispatcher" -->
        
    <!-- default result name is "success" -->
        
    <result>foo.jsp</result>
        
    <result name="error">error.jsp</result>
        
    </result>
      
    </action>
    </package>

    Result類型

    Webwork提供了一些com.opensymphony.xwork.Result接口的實(shí)現(xiàn)來使你的action可以容易的用戶交互.這些Result類型包括:

    Result定義在xwork xml配置文件(xwork.xml)中的action標(biāo)簽里。如果location參數(shù)是result標(biāo)簽的唯一的參數(shù),你可以這樣簡化:

    
    
    <action name="bar" class="myPackage.barAction">
      
    <result name="success" type="dispatcher">
        
    <param name="location">foo.jsp</param>
      
    </result>
    </action>

    或者

    
    
    <action name="bar" class="myPackage.barAction">
      
    <result name="success" type="dispatcher">foo.jsp</result>
    </action>

    如果你擴(kuò)展了webwork-default.xml, 那么默認(rèn)的返回類型是"dispatcher". 同樣,如果你沒有指定result的名字,默認(rèn)將是"success". 就是說你可以如下簡化:

    
    
    <action name="bar" class="myPackage.barAction">
      
    <result>foo.jsp</result>
    </action>

    注意 : Parse屬性允許的location參數(shù)作為表達(dá)式.例如你可以這樣用:
    Struts2中從一個(gè)Action跳轉(zhuǎn)到另一個(gè)action,必須將type="redirect"

    
    
    <result name="success" type="redirect">/displayCart.action?userId=${userId}</result>

    注意 : 你也可以指定全局Result以便在多個(gè)action中使用. 當(dāng)要為很多不同的action添加相同的結(jié)果是這樣會(huì)節(jié)省時(shí)間. Result標(biāo)簽和全局Result的更多信息,參見Result配置部分
    原文



    posted on 2007-12-03 23:11 々上善若水々 閱讀(30746) 評(píng)論(0)  編輯  收藏 所屬分類: Struts2

    主站蜘蛛池模板: 亚洲AV无码一区二三区 | 亚洲国产系列一区二区三区| 亚洲精品成人a在线观看| 成人无码区免费A片视频WWW | 亚洲日韩在线观看| 成年人在线免费观看| 日韩中文字幕免费视频| 精品97国产免费人成视频| 亚洲精品av无码喷奶水糖心| 亚洲美女人黄网成人女| 久久精品国产69国产精品亚洲| 免费观看理论片毛片| 97国产免费全部免费观看| 国产白丝无码免费视频| 九一在线完整视频免费观看| 亚洲AV香蕉一区区二区三区| 亚洲午夜精品一区二区公牛电影院| 亚洲春色在线视频| 国产成人精品日本亚洲专区| 免费a级毛片永久免费| 免费精品一区二区三区在线观看| 日本h在线精品免费观看| 午夜视频在线免费观看| APP在线免费观看视频| 中文字幕在线观看免费| a高清免费毛片久久| 人碰人碰人成人免费视频| 免费一区二区三区在线视频| 激情无码亚洲一区二区三区| 亚洲精品日韩一区二区小说| 亚洲欧美国产欧美色欲| 亚洲日本VA午夜在线影院| 亚洲乱码在线观看| 国产成人精品日本亚洲专| 亚洲视频在线观看2018| 亚洲免费在线视频播放| 亚洲制服丝袜第一页| 一本色道久久88—综合亚洲精品| 国产成人亚洲综合网站不卡| 中文字幕亚洲码在线| 国产亚洲中文日本不卡二区|