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

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

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

    隨筆-21  評(píng)論-29  文章-0  trackbacks-0
    接著學(xué)習(xí)struts的相關(guān)組件
    Action Mapping
     每一個(gè)<action>元素都與類org.apache.struts.action.ActionMapping的一個(gè)實(shí)例對(duì)應(yīng),包括name,path,forward。

    An ActionMapping represents the information that the controller, RequestProcessor, knows about the mapping of a particular request to an instance of a particular Action class. The ActionMapping instance used to select a particular Action is passed on to that Action, thereby providing access to any custom configuration information included with the ActionMapping object.

    下面利用Action Mapping的相關(guān)方法 測(cè)試得到Action Mapping的屬性值
    AddStudentAction增加以下代碼
     //test the ActionMapping
            String name = mapping.getName();
            String path 
    = mapping.getPath();
            String type 
    = mapping.getType();
            System.out.println(
    "name="+name+"\tpath="+path+"\ttype="+type);
            String[] forwardsNames 
    = mapping.findForwards();
            
    for(String forwardName:forwardsNames){
                ActionForward forward 
    = mapping.findForward(forwardName);
                String forwardPath 
    = forward.getPath();
                System.out.println(
    "forwardname="+forwardName+"\tforwardPath"+forwardPath);
            }

            

    重新部署web應(yīng)用 觀察控制臺(tái)輸出

    其與struts-config.xml中的代碼對(duì)應(yīng)
    <action-mappings>
              
    <action path="/addStudentAction" type="cn.itcast.AddStudentAction" name="addStudentForm">
             
    <forward name="addStudentSuccess" path="/AddStudentSuccess.jsp"></forward>
             
    <forward name="addStudentFailure" path="/AddStudent.jsp"></forward>
         
    </action>
         
         
      
    </action-mappings>
    注意:外部不可以使用set方法不能設(shè)置其屬性  因?yàn)榕渲梦募呀?jīng)被frozen!

    ActionForward(導(dǎo)航器)
           ActionForward對(duì)象是配置對(duì)象。這些配置對(duì)象擁有獨(dú)一無(wú)二的標(biāo)識(shí)以允許它們按照name屬性等來(lái)檢索。ActionForward對(duì)象封裝了向前進(jìn)的URL路徑且被請(qǐng)求處理器用于識(shí)別目標(biāo)視覺。
           name:邏輯名稱
           path:頁(yè)面或者模塊訪問(wèn)路徑

    An ActionForward represents a destination to which the controller, RequestProcessor, might be directed to perform a RequestDispatcher.forward or HttpServletResponse.sendRedirect to, as a result of processing activities of an Action class. Instances of this class may be created dynamically as necessary, or configured in association with an ActionMapping instance for named lookup of potentially multiple destinations for a particular mapping instance.

    An ActionForward has the following minimal set of properties. Additional properties can be provided as needed by subclassses.

    • contextRelative - Should the path value be interpreted as context-relative (instead of module-relative, if it starts with a '/' character? [false]
    • name - Logical name by which this instance may be looked up in relationship to a particular ActionMapping.
    • path - Module-relative or context-relative URI to which control should be forwarded, or an absolute or relative URI to which control should be redirected.
    • redirect - Set to true if the controller servlet should call HttpServletResponse.sendRedirect() on the associated path; otherwise false. [false]
    redirec:
        fale,no    ————      RequestDispatcher.forword  路徑相對(duì)當(dāng)前應(yīng)用
        true,yes  ————      HttpServletResponse.sendRedirec.path 寫絕對(duì)路徑

    ActionForm
       工作原理
    處理ActionForm的一般步驟:
       (1)檢查Action的映射,確定Action中已經(jīng)配置了對(duì)ActionForm的映射。
       (2)根據(jù)name屬性,查找form bean的配置信息。
       (3)檢查Action的form bean的使用問(wèn)題,確定在此范圍下(request,session),是否已經(jīng)有此form bean的實(shí)例。
       (4)假如當(dāng)前范圍下,已經(jīng)存在了此form bean的實(shí)例,而是對(duì)當(dāng)前請(qǐng)求來(lái)說(shuō),是同一種類型的話,那么就重用。
       (5)否則,就重新構(gòu)建一個(gè)form bean的實(shí)例(調(diào)用構(gòu)造方法),并且保存在一定作用范圍。
       (6) form bean的reset()方法被調(diào)用
       (7)調(diào)用對(duì)應(yīng)的setter方法,對(duì)狀態(tài)屬性賦值
       (8)如果validate的屬性設(shè)置為true,那么就調(diào)用form 備案的validate方法。
       (9)如果validate方法沒有返回任何錯(cuò)誤,控制器將ActionForm作為參數(shù),傳給Action實(shí)例的execute方法執(zhí)行。
    注意:直接從ActionForm類繼承的reset和validate方法,并不能實(shí)現(xiàn)什么處理功能,所以有必要自己重新覆蓋。



    總覺得學(xué)習(xí)組件有點(diǎn)無(wú)聊,也許明天開始學(xué)習(xí)另外一個(gè)實(shí)例。其他組件過(guò)段時(shí)間再學(xué)習(xí)了!
    posted on 2009-05-03 14:21 特立獨(dú)行 閱讀(1639) 評(píng)論(0)  編輯  收藏 所屬分類: Struts框架
    主站蜘蛛池模板: 亚洲成av人片在线天堂无| 在线观看免费中文视频| 亚洲中文无码永久免费 | 成人毛片100免费观看| 国产成人青青热久免费精品| 亚洲日本中文字幕天天更新| 亚洲精品免费网站| 亚洲最大福利视频| 免费观看的a级毛片的网站| 亚洲愉拍一区二区三区| 国产精品视_精品国产免费| 国产AV无码专区亚洲AV琪琪| 午夜亚洲国产成人不卡在线| 一级毛片视频免费| 亚洲国产精品嫩草影院在线观看 | 久久精品无码一区二区三区免费 | 成人免费看吃奶视频网站| 亚洲av永久中文无码精品综合 | 久久久精品午夜免费不卡| 亚洲精品国产成人专区| 黄色成人免费网站| 亚洲老熟女五十路老熟女bbw| 老司机永久免费网站在线观看| 国产亚洲午夜精品| 亚洲精品国产美女久久久| 99在线免费观看视频| 亚洲av无码不卡久久| 国产91久久久久久久免费| 国产精品青草视频免费播放| 久久久久久亚洲精品| 色婷婷7777免费视频在线观看| 精品亚洲成a人在线观看| 亚洲精品无码久久久久sm| 在线观看免费人成视频色9| 视频一区二区三区免费观看| 亚洲成av人片天堂网| 最近中文字幕免费mv视频7| 一区二区三区免费高清视频| 亚洲精品国产成人中文| 免费国产a国产片高清| 免费人成毛片动漫在线播放|