Tin's Blog

          You are coming a long way, baby~Thinking, feeling, memory...

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            128 隨筆 :: 0 文章 :: 221 評(píng)論 :: 0 Trackbacks

          今天遇到一個(gè)問(wèn)題,在Webwork 2.2里面給一個(gè)Action的result傳多個(gè)參數(shù):
          原先配置如下

          <action name="blahblahAction" class="blahAction" method="blah">
             
          <result name="success" type="redirect">/some.action?field1=${field1}&field2=${field2}</result>
          </action>

          運(yùn)行時(shí)候出現(xiàn)如下提示:
          The reference to entity "field2" must end with the ';' delimiter.
          我本以為是OGNL的問(wèn)題,四處搜尋,不得其解……看了DTD也沒(méi)有發(fā)現(xiàn)問(wèn)題。
          后來(lái)修改過(guò)程中突然發(fā)現(xiàn)原來(lái)是SAX解析器出錯(cuò),我這才想到可能是XML的問(wèn)題。
          經(jīng)過(guò)再三查詢得到解決方案:
          使用"&amp;"代替"&",原理和HTML中的轉(zhuǎn)義相同,我居然忘記了XML的語(yǔ)法規(guī)范,慚愧。
          配置如下:

          <action name="blahblahAction" class="blahAction" method="blah">
             
          <result name="success" type="redirect">/some.action?field1=${field1}&amp;field2=${field2}</result>
          </action>

          工作正常了!希望對(duì)大家有用。
          這幾天超忙,沒(méi)怎么寫(xiě)B(tài)log,還是要勤呀。

          posted on 2006-02-24 13:56 Tin 閱讀(6206) 評(píng)論(17)  編輯  收藏 所屬分類: Webwork相關(guān)

          評(píng)論

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2006-02-24 17:27 keigo
          <param name = "paraA">xx1</param>
          <param name = "paraB">xx2</param>
          這種方式不就行啦  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2006-02-25 00:04 Tin
          呵呵,可能你看錯(cuò)了。這里是說(shuō)對(duì)result的多參數(shù)進(jìn)行配置,而不是對(duì)action的參數(shù)進(jìn)行配置,兩者所處的Action生命周期不同。<param>參數(shù)負(fù)責(zé)給Action初始化賦值,而對(duì)result不能通過(guò)<param>賦值,在result type="redirect"時(shí)相當(dāng)于Action生命周期結(jié)束并將參數(shù)傳給下一個(gè)action或者一些url觸發(fā)的事件。

          其實(shí)上面的代碼如果不簡(jiǎn)寫(xiě),將所有的參數(shù)指明是這樣的:
          <action name="blahblahAction" class="blahAction" method="blah">
          <result name="success" type="redirect">
          <param name="location">/some.action?field1=${field1}&amp;field2=${field2}</param>
          <param name="parse">true</param>
          </result>
          </action>
          因?yàn)閠ype="reirect"的result只接受location和parse兩個(gè)參數(shù),不支持自定義的param,這是個(gè)限制。這個(gè)限制可以在webwork的wiki上面搜索到。希望以后webwork可以改變它。不過(guò)lightbody本人也許覺(jué)得OGNL的表達(dá)式已經(jīng)夠強(qiáng)大了,呵呵:D  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2006-03-29 11:01 testtest
          只要在xml文件中;號(hào)都要被&amp;替代,這個(gè)我早就會(huì)了,想不到高手還會(huì)為這個(gè)寫(xiě)blog.哧哧。。  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2006-03-31 15:35 Snow
          "這個(gè)我早就會(huì)了"---明顯的小人得志,沒(méi)見(jiàn)過(guò)那個(gè)真正的高手說(shuō)這話,自己會(huì)了譏笑別人不會(huì),這是什么作風(fēng),最看不慣了!!
          我覺(jué)得樓主的的帖子對(duì)本人非常管用,我正在苦苦的搜索相關(guān)的問(wèn)題呢,頂一個(gè)!!!  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2006-04-09 00:45 testtest
          @Snow

          sb,我又不是高手,我也沒(méi)說(shuō)自已是高手。
            回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2007-01-16 17:10 ccmv
          你好,請(qǐng)問(wèn)給/some.action?field1=${field1}&amp;field2=${field2}
          ${field1} ${field2}傳值  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù)[未登錄](méi) 2007-04-03 16:24 jack
          請(qǐng)問(wèn)我在傳遞參數(shù)是為什么只能得到一個(gè)參數(shù)?
          比如:
          <action name="actionName" class="someAction" method="someMethod">
          <result name="success" type="redirect">
          <param name="location">anotherAction.action?param1=${param1}&amp;param2=${param2}</param>
          <param name="parse">true</param>
          </result>
          </action>

          重定向后,我在Action中只能得到第一個(gè)參數(shù)(parameters.size() == 1),第二個(gè)參數(shù)丟失了。
          請(qǐng)問(wèn)您知道什么原因嗎?
          cnlf@sina.com  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù)[未登錄](méi) 2007-06-28 17:43 野草
          感謝作者!解決了個(gè)問(wèn)題。順便鄙視一下那個(gè)小人得志testtest╭∩╮(︶︿︶)╭∩╮。  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2007-07-17 18:19 網(wǎng)友
          第二個(gè)參數(shù) 丟了, 是什么原因 , 我一碰到這個(gè)問(wèn)題.
          xuzhibing0907@163.com  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2007-07-18 14:36 Tin
          第二個(gè)不會(huì)丟,用&amp;就可以了。  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2007-11-20 11:32 biby
          謝謝!!正是我要的  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2008-04-17 17:12 曉秋
          Cannot create a session after the response has been committed

          我用這個(gè)出現(xiàn)了這個(gè)問(wèn)題,請(qǐng)教一下.有沒(méi)有解決方案.  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù)[未登錄](méi) 2008-06-24 13:46 test
          謝謝,我也遇見(jiàn)這個(gè)問(wèn)題了!  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù)[未登錄](méi) 2008-06-24 13:47 test
          我也遇見(jiàn)這個(gè)問(wèn)題了!  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù) 2008-10-06 21:42 wwb
          /selectMinusPricing.action?s1=${sessionScope.serviceuser.userId}

          我的為什么得不到 輸出s1=0;  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù)[未登錄](méi) 2009-04-23 10:54 aaa
          謝謝樓主,
          testtest就是一個(gè)山炮  回復(fù)  更多評(píng)論
            

          # re: 如何給Webwork的redirect的result傳遞多個(gè)參數(shù)[未登錄](méi) 2009-06-07 20:02 dd
          ddd@keigo
            回復(fù)  更多評(píng)論
            

          主站蜘蛛池模板: 南投县| 普兰店市| 定州市| 页游| 平顺县| 彭州市| 木里| 睢宁县| 沙湾县| 靖宇县| 沙河市| 油尖旺区| 元朗区| 潼南县| 南漳县| 建瓯市| 玛多县| 大渡口区| 洛宁县| 延长县| 海伦市| 泸水县| 遂昌县| 二手房| 康定县| 专栏| 榆社县| 建湖县| 堆龙德庆县| 青田县| 广宁县| 改则县| 聂拉木县| 民权县| 沅陵县| 名山县| 湘乡市| 凤冈县| 来安县| 台东县| 曲靖市|