Flex2與Struts整合配置-續搭建免費的flex開發環境flashdevelop

Flex2與Struts整合配置
-續搭建免費的flex開發環境flashdevelop

1.下載軟件
a)Flex data service:
http://www.adobe.com/products/flex/
b)struts:
http://struts.apache.org/download.cgi
c)Tomcat:
http://tomcat.apache.org/download-55.cgi

2.安裝軟件
a)安裝flex data service,如果是試用選擇集成jrun安裝。
b)解壓下載的struts-1.x.x-bin.zip包,到任意位置。
c)解壓下載的apache-tomcat-5.5.20.zip,到任意位置。

3.將空白fds2應用與空白struts應用整合到Tomat中
a)拷貝C:\fds2\jrun4\servers\default下面的flex文件夾到Tomcat_home\webapps下面
b)拷貝struts-1.x.x-bin\webapps下面的struts-blank.war文件到Tomcat_home\webapps下面
c)啓動tomcat
d)拷貝Tomcat_home\webapps\struts-blank\WEB-INF\lib下面的jar包到Tomat_home\webapps\flex\WEB-INF\lib下面,有重複的覆蓋
e)拷貝Tomcat_home\webapps\struts-blank\WEB-INF\web.xml文件中的11~27句(action定義段)到Tomat_home\webapps\flex\WEB-INF\web.xml文件中的servlet定義段
f)拷貝Tomcat_home\webapps\struts-blank\WEB-INF\web.xml文件中的31~34句(servlet-mapping定義段)到Tomat_home\webapps\flex\WEB-INF\web.xml文件中的servlet-mapping定義段
g)拷貝Tomcat_home\webapps\struts-blank\WEB-INF\struts-config.xml文件拷貝到Tomat_home\webapps\flex\WEB-INF目錄下
h)刪除Tomat_home\webapps\flex\WEB-INF\struts-config.xml中的plug-in定義段落
i)關閉Tomcat(ctrl+c)

4.測試整合配置正確性
a)拷貝Tomcat_home\webapps\struts-blank\下面的pages文件夾到Tomat_home\webapps\flex下面
b)打開Tomat_home\webapps\flex\pages\Welcome.jsp文件,刪除全部內容,改爲以下內容:

xml 代碼
  1. <%@ page contentType="text/xml;charset=UTF-8" language="java" %>    
  2. <%    
  3. out.println("<ok><hi/></ok>");    
  4. %>  


c)在xml編輯工具中建立一個App.mxml文件,內容如下:

xml 代碼
  1. <?xml version="1.0" encoding="utf-8"?>    
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">    
  3. <mx:Script>    
  4. <![CDATA[   
  5. import mx.controls.Alert;   
  6. import mx.events.CloseEvent;   
  7. ]]>    
  8. </mx:Script>    
  9. <mx:HTTPService id="registrationRequest" url="Welcome.do" useProxy="false" result="Alert.show('Hello World!', 'Message');" showBusyCursor="true" fault="Alert.show('Error!', 'Message');" resultFormat="e4x"/>    
  10. <mx:Button label="Register" click="registrationRequest.send();"/>    
  11. <mx:TextArea width="200" height="100" x="0" y="30" text="{registrationRequest.lastResult.toString()}"/>    
  12. </mx:Application>    

d)啓動Tomcat
e)在瀏覽器中訪問:http://localhost:8080/flex/App.mxml
如果能看到Hello World的提示窗口,和<ok><hi/></ok>的字符就表示配置成功了!

發佈了0 篇原創文章 · 獲贊 0 · 訪問量 2236
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章