隨筆-8  評(píng)論-19  文章-2  trackbacks-0

          在WebWork 2.2.1中,在配置文件xwork.xml中新增加了了一個(gè)元素: default-action-ref,其實(shí)這個(gè)配置非常簡(jiǎn)單,但是很多人不知道,所以簡(jiǎn)單介紹一下.

          如果你在xwork.xml里面配置了default-action-ref,那么當(dāng)xwork中沒有找到對(duì)應(yīng)的action時(shí),默認(rèn)就會(huì)調(diào)用default-action-ref指定的action.

          官方的wiki文檔參考這里: http://wiki.opensymphony.com/display/WW/Action+configuration

          配置代碼如下:

           

          												<package name="myPackage" ....>
                      ...
                      <default-action-ref name="simpleViewResultAction">
                      <!--
                      An example of a default action that is just a simple class
                      that has 3 fields: successUrl, errorUrl, and inputUrl.  This action
                      parses the request url to set the result values.  In the normal case
                      it just renders velocity results of the same name as the requested url.
                      -->
                      <action name="simpleViewResultAction" class="SimpleViewResultAction">
                      <result type="velocity">${successUrl}</result>
                      
          <result name="error" type="velocity">${errorUrl}</result>
                      <result name="input" type="velocity">${inputUrl}</result>
                      
          </action>
          ... </package>

          但是要注意,一般一個(gè)package內(nèi)配置一個(gè),如果配置多個(gè),就無法預(yù)測(cè)結(jié)果了.

          注意上面的配置,第一個(gè)result的name屬性被省略了,webwork會(huì)認(rèn)為它是"SUCCESS".

          WebWork帶的例子里面就有default-action-ref的配置,可以參考.

          posted on 2007-06-21 14:39 jie_java 閱讀(1233) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 遂溪县| 衡山县| 武汉市| 林甸县| 正宁县| 吉林市| 淮南市| 邵武市| 天长市| 淳安县| 来凤县| 安阳县| 望都县| 和静县| 桐城市| 新疆| 潞西市| 贺兰县| 上虞市| 甘肃省| 林西县| 开封市| 金昌市| 安国市| 揭西县| 普宁市| 日喀则市| 宣化县| 闻喜县| 兰西县| 辽源市| 扬中市| 浮山县| 丹东市| 吉木萨尔县| 阳泉市| 崇文区| 南华县| 襄城县| 鄂托克旗| 泾川县|