flex代码:
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
- <fx:Script>
- <!--[CDATA[
- import mx.controls.*;
- import mx.rpc.events.ResultEvent;
- import mx.rpc.http.mxml.HTTPService;
- protected function button1_clickHandler(event:MouseEvent):void
- {
- var addNew:HTTPService = new HTTPService();
- addNew.resultFormat = "text" ;
- addNew.method = "POST";
- addNew.url = "http://localhost:8084/Flex_web/flex";
- addNew.addEventListener(ResultEvent.RESULT,result_Handler);
- var param:Object = new Object();
- param.user = user.text;
- param.pwd = pwd.text;
- addNew.send(param);
- }
- public function result_Handler(event:ResultEvent):void
- {
- var mes:String = event.message.body.toString();
- Alert.show("成功!" + mes,"信息");
- }
- ]]-->
- </fx:Script>
- <fx:Declarations>
- <!-- Place non-visual elements (e.g., services, value objects) here -->
- </fx:Declarations>
- <s:Panel x="200" y="110" width="224" height="157" title="登录系统">
- <s:Button x="24" y="92" label="登录" click="button1_clickHandler(event)" width="171" focusEnabled="true"/>
- <s:TextInput x="67" y="10" id="user"/>
- <s:TextInput x="67" y="49" id="pwd"/>
- <s:Label x="20" y="15" text="用户名:"/>
- <s:Label x="20" y="55" text="密码:"/>
- </s:Panel>
- </s:Application>
servlet代码:
- package advang;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- public class flexServlet extends HttpServlet {
- protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
- String user = request.getParameter("user");
- String pwd = request.getParameter("pwd");
- user = new String(user.getBytes("ISO8859-1"),"UTF-8");
- pwd = new String(pwd.getBytes("ISO8859-1"),"UTF-8");
- PrintWriter out = response.getWriter();
- try {
- out.print("从服务器返回的数据[" + user + "][" + pwd + "]!");
- } finally {
- out.close();
- }
- }
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- @Override
- public String getServletInfo() {
- return "Short description";
- }
- }
相关推荐
flex通过httpService读取xml数据到datagird中,通过读取远程URL的XML数据(这里保存到本地),保存到ArrayCollection中,然后在将ArrayCollection绑定到datagird上 环境:flex3.0 可直接运行
flex用httpService通信与java后台连接
flex通过Http和WebService与服务器通信交互,交互后台采用java的Struts2做为处理后台.
flex4 httpservice 例子 提取xml数据
一个flex 与 java 通过HTTPService 通信的小例子,希望对flex新手有点帮助
简单的 flex HttpService例子,可供初学者参考
Flex使用HttpService以键值对的形式发送请求,Java使用Servlet接收Flex请求,再返回数据给Flex客户端。 有文档有例子 包括java 和 flex
FLEX _HTTPService的调用方法 显示数据的例子 QueryDataSet.xml
flex 和java的通信使用的是httpservice 但当时遇到了不知道如何获取java端的返回值给flex前端 我这个就是为了解决你烦恼而来的 绝对不忽悠你
NULL 博文链接:https://topmanopensource.iteye.com/blog/425794
这是本人做的Flex4 通过HttpService与Java进行交互项目,本人测试通过。本人在此声明运行环境为:MyEclipse 8.5,JDK 6,Tomcate 6,Flex 4. 本人已经将Flex4整合到Myeclipse 8.5中去了,所以这个项目是在MyEclipse ...
Flex HTTPService 如何给后台传递参数 包含实例绝对简单
FLEX与JSP结合并测试HTTPService与java用XML通信
Flex 使用HttpService组件发送XML数据与java交互 例子+文档
flex4出来一段时间了,去年看了一段时间flex3,后来由于暂时没有项目需求.所以flex遗忘了很多.这次使用flex4+myeclipse8.5录制了一个视频.... 2 flex 与服务器交互HTTPService 3 flex与webservice交互WebService
FLEX与JSP结合并测试HTTPService与java用XML通信.doc
本文简单介绍了Flex如何通过servlet连接数据库(Access)。使用的是<mx:HttpService>给后台传递数据的方法。 本文开发使用的软件: Flex3-eclipse plugin Tomcat 6.0 Microsoft access 2003 Eclipse 3.3 ...