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

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

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

    隨筆-21  評論-29  文章-0  trackbacks-0
    接著學習struts的相關組件
    Action Mapping
     每一個<action>元素都與類org.apache.struts.action.ActionMapping的一個實例對應,包括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的相關方法 測試得到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應用 觀察控制臺輸出

    其與struts-config.xml中的代碼對應
    <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方法不能設置其屬性  因為配置文件已經被frozen!

    ActionForward(導航器)
           ActionForward對象是配置對象。這些配置對象擁有獨一無二的標識以允許它們按照name屬性等來檢索。ActionForward對象封裝了向前進的URL路徑且被請求處理器用于識別目標視覺。
           name:邏輯名稱
           path:頁面或者模塊訪問路徑

    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  路徑相對當前應用
        true,yes  ————      HttpServletResponse.sendRedirec.path 寫絕對路徑

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



    總覺得學習組件有點無聊,也許明天開始學習另外一個實例。其他組件過段時間再學習了!
    posted on 2009-05-03 14:21 特立獨行 閱讀(1639) 評論(0)  編輯  收藏 所屬分類: Struts框架
    主站蜘蛛池模板: 久久精品国产亚洲Aⅴ香蕉| 国产精品麻豆免费版| 国产AV无码专区亚洲AWWW| 精品免费AV一区二区三区| 国产精品国产免费无码专区不卡| 亚洲av无码一区二区三区天堂古代| 91成人在线免费观看| 亚洲黄色网址大全| 免费看片在线观看| 亚洲最大的成人网| 女人被免费视频网站| 蜜芽亚洲av无码一区二区三区| 成人性生免费视频| 色偷偷噜噜噜亚洲男人| 亚洲不卡AV影片在线播放| 国产免费黄色无码视频| 亚洲国产精品久久久天堂| 日本人的色道免费网站| 亚洲一区二区无码偷拍| 国产又长又粗又爽免费视频| 理论片在线观看免费| 亚洲精品成人片在线观看精品字幕| 在线免费观看h片| 亚洲国产精品专区| 情侣视频精品免费的国产| eeuss草民免费| 精品无码一区二区三区亚洲桃色 | 一本色道久久88亚洲精品综合| 天天天欲色欲色WWW免费| 香蕉视频免费在线播放| 亚洲精品成人无码中文毛片不卡| 亚洲免费在线视频播放| 美女黄频免费网站| 亚洲一区二区三区日本久久九| 99热在线精品免费全部my| 污视频网站在线免费看| 久久精品蜜芽亚洲国产AV| 亚洲成A人片在线观看无码3D| 久久国产精品免费观看| 亚洲精品国产suv一区88| 亚洲精品无码mv在线观看网站|