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

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

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

    風人園

    弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
    隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
    數據加載中……

    struts2--Result Configuration

     

    當Action類方法完成,會返回一個字符串,這個字符串值用來選擇result元素。一個action可以映射到一組不同描述的結果。標準的result是在ActionSupport 這個基類中定義的。

    String SUCCESS = "success";
    String NONE    
    = "none";
    String ERROR   
    = "error";
    String INPUT   
    = "input";
    String LOGIN   
    = "login";

    當然,ap可以自定義其他的result標記來match特定的情況。

    Result Elements
    result有默認值設定,如果不指定屬性,則使用success和dispatch來執行這個result

    <action name="Hello">
      
    <result>/hello/Result.jsp</result>
      
    <result name="error">/hello/Error.jsp</result>
      
    <result name="input">/hello/Input.jsp</result>
    </action>


    如上顯示,默認情況下,如果返回值是success,則執行第一個result,其他的情況執行下面的匹配的result

    Global Results

    大部分時候,results都是嵌套在antion元素中。但是很多results會應用到不同的action。在一個安全的應用中,一個client試圖訪問一個沒有認證的頁面,那么很多action可能都需要去訪問 logon result。
    如果action需要共享result, 一組global result可以為每一個package定義??蚣苁紫炔樵兦短自赼ction中的本地result,如果本地result沒有符合的,則在global result中查詢。

    <global-results>
      
    <result name="error">/Error.jsp</result>
      
    <result name="invalid.token">/Error.jsp</result>
      
    <result name="login" type="redirect-action">Logon!input</result>
    </global-results>

     

    Dynamic Results
    A result may not be known until execution time. Consider the implementation of a state-machine-based execution flow; the next state might depend on any combination of form input elements, session attributes, user roles, moon phase, etc. In other words, determining the next action, input page, etc. may not be known at configuration time.

    Result values may be retrieved from its corresponding Action implementation by using EL expressions that access the Action's properties, just like the Struts 2 tag libraries. So given the following Action fragment:
    一個action有時候不可能在執行前就知道它的action,這種情況就需要通過動態result來實現。

     首先定義一個屬性,來存放這個值,然后在流程定義中通過EL表達式來取得這個屬性值。這樣就可以通過程序動態指定需要轉發的值。

    private String nextAction;

       public String getNextAction() {
           
    return nextAction;
       }

    you might define a result like this:
    <action name="fragment" class="FragmentAction">
            
    <result name="next" type="redirect-action">${nextAction}</result>
    </action>
    If a FragmentAction method returns "next" the actual value of that result will be whatever is in FragmentAction's nextAction property. So nextAction may be computed based on whatever state information necessary then passed at runtime to "next"'s redirect-action.

    總結,struts2對于result提供了很多很靈活的設置方法,用戶可以使用相應的方法處理特定的邏輯。對于各種情況,總能找出相應的方法來出來。

    posted on 2007-06-27 11:29 風人園 閱讀(2865) 評論(0)  編輯  收藏 所屬分類: Struts2

    主站蜘蛛池模板: 亚洲狠狠成人综合网| 亚洲欧洲日产国产综合网| 亚洲一区二区三区深夜天堂| 中文字幕成人免费高清在线视频| 国产午夜无码视频免费网站 | 亚洲欧洲日产国产综合网| 暖暖日本免费中文字幕| 亚洲av日韩av高潮潮喷无码| 免费A级毛片av无码| 日本久久久久亚洲中字幕| 国产精彩免费视频| 亚洲中文字幕无码爆乳app| 免费看美女被靠到爽的视频| 亚洲av永久无码| 亚洲精品成人区在线观看| AAAAA级少妇高潮大片免费看| 国产亚洲无线码一区二区| 一区二区免费视频| 亚洲人成毛片线播放| 日韩精品无码人妻免费视频 | 亚洲毛片αv无线播放一区| A片在线免费观看| 亚洲黄色网站视频| 性一交一乱一视频免费看| 免费无码又爽又黄又刺激网站| 亚洲日韩国产一区二区三区| 国产亚洲免费的视频看| 亚洲日本在线免费观看| 国产高清视频在线免费观看| 中国性猛交xxxxx免费看| 亚洲精品人成电影网| 蜜桃精品免费久久久久影院| 国产免费黄色无码视频| 亚洲欧洲国产成人精品| 免费在线观看视频a| 99ee6热久久免费精品6| 亚洲Aⅴ在线无码播放毛片一线天| 中文字幕亚洲无线码| 久久99九九国产免费看小说| 黄网站色视频免费看无下截| 亚洲狠狠ady亚洲精品大秀|