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

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

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

    我的漫漫程序之旅

    專注于JavaWeb開發
    隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
    數據加載中……

    Struts2中的Result類型應用(action...etc跳轉)

    概況

    Result類型 是在Action執行完,一個結果返回后決定發生什么事的類。開發者可以自由的根據他們的應用和環境的需要創建自己的Result類型。例如在WebWork2中,Servlet和Velocity結果類型已經被創建用來顯示web應用程序的畫面。

    注意: 所有的webwork內建的Result類型都實現了com.opensymphony.xwork.Result接口. 這個接口是所有action執行結果的通用接口,不管這個結果是用來顯示一個網頁還是產生一個email,發送一個JMS消息,等.

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

    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接口的實現來使你的action可以容易的用戶交互.這些Result類型包括:

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

    
    
    <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>

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

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

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

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

    注意 : 你也可以指定全局Result以便在多個action中使用. 當要為很多不同的action添加相同的結果是這樣會節省時間. Result標簽和全局Result的更多信息,參見Result配置部分
    原文



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

    主站蜘蛛池模板: 综合偷自拍亚洲乱中文字幕| 日日麻批免费40分钟日本的| 亚洲日本国产精华液| 亚洲av无码不卡私人影院| 国产免费毛不卡片| 国产成人精品一区二区三区免费| 亚洲av无码一区二区三区人妖 | 亚洲天堂中文字幕在线观看| 国产自偷亚洲精品页65页| 日本免费一区二区三区最新vr| 最近免费中文字幕高清大全| 国产99久久久国产精免费| 久久精品熟女亚洲av麻豆| 亚洲天堂2016| 777亚洲精品乱码久久久久久| 久久久久国产成人精品亚洲午夜| 国产成人精品免费直播| 搡女人真爽免费视频大全| 国内精自视频品线六区免费 | 亚洲一区二区电影| 亚洲人成网站在线播放vr| 亚洲黄片手机免费观看| 四虎影视精品永久免费| 日韩高清免费在线观看| 四虎在线免费播放| 性xxxx视频播放免费| 毛片基地免费观看| 毛片a级毛片免费观看免下载| 免费观看无遮挡www的视频 | 亚洲国产av一区二区三区丶| 久久亚洲精品成人777大小说| 国产亚洲3p无码一区二区| 亚洲理论电影在线观看| 亚洲AV永久精品爱情岛论坛| 亚洲成av人影院| 亚洲av色影在线| 内射少妇36P亚洲区| 亚洲欧洲校园自拍都市| 国产精品亚洲专区在线观看| 亚洲最大的成人网| 亚洲av日韩aⅴ无码色老头|