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

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

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

    posts - 13, comments - 7, trackbacks - 0, articles - 0
    action mapping中的attribute 屬性到底是干什么用的, 很早以前一直不太了解,今天突然又想到了這個問題,感覺不能再扔一邊不管了, 一定要解決它.


    這是在網上查到的關于attribute的解釋.
    1)應用前提,attribute只有在設置了name后才有意義。
    2)attribute可以實現對象的重用,即如果設置了attribute屬性,在創建actionform是,會先去查找相應的scope中是否有此對象,如果有,則重用,否則創建新的對象。
    3)當你將創建的acitonForm保存到相應的scope中時,你想用一個更有意義的名字來訪問它時,它就有意義了。

    可是,看到"一個更有意義的名字的時候", 我好像有點理解了
    <action
    attribute="newLoginForm"
    name="loginForm"
    type="loginAction"
    scope="request"
    path="/login">


    在struts實例化actionform的時候,struts是根據attribute的值來查找并創建actionform,有兩種情況:如果已經存在,那么從內存中取回;如果第一次實例化,那么創建,并放入內存。

    org.apache.struts.util.RequestUtils中的源代碼

    ???public static Actionform createActionform(
    ? ? ? ?HttpServletRequest request,
    ? ? ? ?ActionMapping mapping,
    ? ? ? ?ModuleConfig moduleConfig,
    ? ? ? ?ActionServlet servlet) {
    ?????? ............
    ??????............

    ???????String attribute = mapping.getAttribute();
    ??????......
    ???????Actionform instance = null;
    ? ? ? ?HttpSession session = null;

    ???????if ("request".equals(mapping.getScope())) {
    ? ? ? ? ? ?instance = (Actionform) request.getAttribute(attribute);
    ? ? ? ?} else {
    ? ? ? ? ? ?session = request.getSession();
    ? ? ? ? ? ?instance = (Actionform) session.getAttribute(attribute);
    ? ? ? ?}
    ??????................
    ????????................
    ???????
    ???????}
    ???????
    如果沒有配置attribute屬性的話, struts才會從name屬性里讀出要創建的formbean 的名字,并創建一下實例,看下邊的源代碼就知道了, 呵呵.


    org.apache.struts.config.ActionConfig

    ???protected String attribute = null;

    ? ?public String getAttribute() {
    ?//就是這里了.
    ???????if (this.attribute == null) {
    ? ? ? ? ? ?return (this.name);
    ? ? ? ?} else {
    ? ? ? ? ? ?return (this.attribute);
    ? ? ? ?}
    ? ?}

    ? ?public void setAttribute(String attribute) {
    ? ? ? ?if (configured) {
    ? ? ? ? ? ?throw new IllegalStateException("Configuration is frozen");
    ? ? ? ?}
    ? ? ? ?this.attribute = attribute;
    ? ?}

    Feedback

    # re: 關于struts-config里action元素里的attribute屬性用途的理解  回復  更多評論   

    2008-08-07 16:58 by chenhong
    好厲害!

    # re: 關于struts-config里action元素里的attribute屬性用途的理解  回復  更多評論   

    2008-10-20 22:30 by java Primer
    很好,比起亂七八糟的書籍資料,源代碼的學習才是王道
    主站蜘蛛池模板: 久久99精品免费一区二区| 国产.亚洲.欧洲在线| 九九免费观看全部免费视频| 国产极品粉嫩泬免费观看| 国产亚洲精品影视在线| a级毛片无码免费真人| 国产.亚洲.欧洲在线| 精品国产一区二区三区免费看| 亚洲第一成人在线| 处破痛哭A√18成年片免费| 亚洲午夜无码久久| 国产伦一区二区三区免费| 亚洲精品中文字幕| 国产一区二区免费在线| 无人视频免费观看免费视频| 亚洲日韩人妻第一页| 免费无码又爽又刺激一高潮| 亚洲国产成人久久精品影视| 亚洲视频在线观看免费视频| 亚洲国产区男人本色在线观看| 精品久久洲久久久久护士免费 | 免费一看一级毛片| 日韩成人毛片高清视频免费看| 亚洲色欲久久久综合网东京热| 久章草在线精品视频免费观看| 亚洲国产成人精品久久| 成年人免费视频观看| xvideos永久免费入口| 亚洲AV福利天堂一区二区三| 日韩免费a级毛片无码a∨| 国产亚洲漂亮白嫩美女在线| 亚洲va久久久噜噜噜久久男同 | 国产精品免费看久久久久| 一级做a爰片性色毛片免费网站| 亚洲Av无码精品色午夜| 国产精品成人免费一区二区| 大片免费观看92在线视频线视频| 亚洲天天在线日亚洲洲精| 日韩伦理片电影在线免费观看| 国产美女视频免费观看的网站| 亚洲一欧洲中文字幕在线|