传递请求到Java后台自己总结出了三种方式,也是我在项目当中用到的三种方式,今天把它写出来,一是为正在学习flex的新手一个好的指导,二是给自己是一个不忘的笔记: 一,通过httpService向java的servlet发送请求,然后返回一个结果: 第一步新一个httpService.mxml文件: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Button x="277" y="162" label="点击" width="194" height="73" +msg); } ]]> </mx:Script> </mx:Application> 第二步,写一个servlet: package com.lovo;

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 HttpService extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

this.doPost(request, response); }

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=utf-8;"); PrintWriter out = response.getWriter();
String userName = request.getParameter("userName");
String userPwd = request.getParameter("userPwd"); out.print("你输入的姓名为:"+userName+ "密码为:"+userPwd);
}

} 对于httpServlet就介绍完成了。上面代码是通过测试的

更多见:http://www.blogjava.net/yczz/articles/144363.html

相关文章:

  • 2021-11-04
  • 2021-12-29
  • 2021-09-23
  • 2022-12-23
  • 2021-09-26
  • 2021-09-07
  • 2021-11-02
  • 2021-06-12
猜你喜欢
  • 2021-09-07
  • 2021-11-29
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案