Java與Flex學習筆記(11)—-關於Struts2攔截Flex請求的問題

來源:互聯網
上載者:User

       昨天做一個東西時發現原來Flex與Java用RemoteObject通訊好好的方式突然就不行了,我原以為是endpoint的路徑有問題,但是經過仔仔細細的排查也沒有發現問題。總是提示“404”錯誤:




     後來查看控制台的錯誤資訊輸出才發現,由於這次將Struts2整合在一起了,所以,Struts2將此發送請求也攔截了:


There is no Action mapped for namespace/messagebroker and action name amf. - [unknown location]


      上網查了很久的資料發現原因的所在,我們在web.xml中配置Struts2的攔截器時習慣攔截所有的請求,即:


……

  <filter-mapping>

    <filter-name>struts2</filter-name>

    <url-pattern>/*</url-pattern>

  </filter-mapping>

……


      在Flex與Struts2整合的時候如果還是採用這種方式的時候,會導致Flex無法與Struts2用remoteobject通訊,我們應該調整成如下方式:


……

  <filter-mapping>

    <filter-name>struts2</filter-name>

    <url-pattern>*.action</url-pattern>

  </filter-mapping>

……


       即只攔截Struts2的請求,這樣就放過其他的請求,事實上這樣做的確解決了問題,記錄下。


        原創文章,轉載請註明出處:http://www.dianfusoft.com/




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.