(转)flex与servlet交互

转自 http://pipe.**.com/blog/201938

首先,我们在eclipse中创建一个web project  取名为simple

在这个project中我们创建一个servlet:代码如下:


  1. package com.test;   
  2.   
  3. import java.io.IOException;   
  4. import java.io.PrintWriter;   
  5.   
  6. import javax.servlet.ServletException;   
  7. import javax.servlet.http.HttpServlet;   
  8. import javax.servlet.http.HttpServletRequest;   
  9. import javax.servlet.http.HttpServletResponse;   
  10.   
  11. public class TestServlet extends HttpServlet {   
  12.   
  13.        
  14.     public void doGet(HttpServletRequest request, HttpServletResponse response)   
  15.             throws ServletException, IOException {   
  16.             this.doPost(request, response);   
  17.     }   
  18.   
  19.        
  20.     public void doPost(HttpServletRequest request, HttpServletResponse response)   
  21.             throws ServletException, IOException {   
  22.   
  23.         response.setContentType("text/html");   
  24.         PrintWriter out = response.getWriter();   
  25.         out.println("<?xml  version=\"1.0\" encoding=\"UTF-8\"?>");   
  26.         out.println("");   
  27.         out.println("");   
  28.             out.println("pubDate11111");   
  29.             out.println("title111");   
  30.             out.println("description111");   
  31.         out.println("");   
  32.         out.println("");   
  33.             out.println("pubDate222");   
  34.             out.println("title22");   
  35.             out.println("description122211");   
  36.     out.println("");   
  37.     out.println("");   
  38.     }   
  39.   
  40. }  


这个servlet的访问地址为:http://localhost:8080/simple/test,
现在我们在flex buider3中创建一个flex project,选择web root为tomcat/webapps下面, 取名test.
新建一个connect.mxml文件 代码如下:


  1. <?xml  version="1.0" encoding="utf-8"?>   
  2. "http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="feedRequest.send()">   
  3.     "feedRequest" url="http://localhost:8080/simple/test"  
  4.         useProxy="false">   
                        "10" y="10" width="800" height="400" layout="absolute" horizontalAlign="right"           >            "20" y="20" id="dgPosts" width="400" verticalCenter="center" dataProvider="{feedRequest.lastResult.rss.xml}">                                    "标题" dataField="title" />                    "时间" dataField="pubDate"/>                                                        "20" y="175" width="400" height="100" htmlText="{dgPosts.selectedItem.description}"/>                                          


好了!访问一下:http://localhost:8080/test/bin-debug/connect.html
截图如下:
25432352_201103242006311.jpg

fj.pnga2d441f0-3b35-33b6-b19c-5338cc0e12b5[1].JPG

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25432352/viewspace-690411/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25432352/viewspace-690411/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值