flex 端
var request:URLRequest = new URLRequest("http://localhost:8080/requestUrl");
request.method = URLRequestMethod.GET;
var params:URLVariables = new URLVariables(); ;
params.flag ="delete";
request.data = params;
var loader:URLLoader = new URLLoader();
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
private function onLoaderComplete(event : Event):void
{
//servlet端传回来的参数
var str : String = ((event.target) as URLLoader).data;
}
java端
package com;
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 JspServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
response.setContentType("text/html");
String param = (String)request.getParameter("flag"); //取出Flex页面传过来的param
PrintWriter out = response.getWriter();
out.print(param); //返回Flex
out.flush();
out.close();
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
this.doGet(request, response);
}
}