Flex與Java通訊架構搭建的步驟

來源:互聯網
上載者:User

Flex與Java通訊架構搭建的步驟

  Flex與Java通訊架構搭建的步驟:

  1. 建立web項目,並啟動tomcat運行,檢查一切是否正常(必須);

  2. 匯入所需的jar包(我已給出),將需要用的四個XML資源檔:messaging-config.xml,proxy-config.xml,remoting-config.xml,services-config.xml全部複製粘貼到項目的WEB-INF檔案夾下,如所示:

  3. 修改web.xml檔案:將如下內容全部粘貼到web.xml中,不需做任何的更改即可;

  flex.class.path

  /WEB-INF/flex/hotfixes,/WEB-INF/flex/jars

  flex.messaging.HttpFlexSession

  MessageBrokerServlet

  flex.messaging.MessageBrokerServlet

  services.configuration.file

  /WEB-INF/flex/services-config.xml

  1

  MessageBrokerServlet

  /messagebroker/*

  4. 添加Flex project支援,並發布web工程(必須),如:

  ----↓↓

  註:一定要按上面的圖解來做,否則是很難配置成功的!

  5. 在此項目中建立類FirstFlex

  public class FirstFlex {

  public String hello(String name) {

  return "你好! " + name;

  }

  }

  6.並在remoting-config.xml中添加如下代碼:配置該類

  com.alex.flex.FirstFlex

  7. 修改Flex編譯版本,否則無法產生SWF。(工程上右擊,選擇properties)

  8. 在MXML中調用java處理類

  

  import mx.rpc.events.ResultEvent;

  function rest(event:ResultEvent):void {

  rest_ta.text = event.result as String;

  }

  function remotingSayHello():void {

  h.hello(inp.text);

  }

  ]]>

  //暴露對象

  9. 當伺服器啟動後,工程會自動將flex目錄和swf發布到webApps下。

  10.嘿嘿,可以看到,簡單的flex與Java通訊已經成功!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.