Flex3通过HttpService与java通信

mxml 文件:
<mx:HTTPService
        id="yourid"
        url="servlet url"
        resultFormat="e4x"
        useProxy="false" />

public function result1(event:ResultEvent):void
{
var rxml : XML = XML(event.result);
Alert.show(rxml.id+"YY");
}
public function add():void
{
yourid.addEventListener(ResultEvent.RESULT,result1);
myHttpService.method = "POST";
        params:Object = {"method": "save", "id":youinfo};
myHttpService.cancel();
myHttpService.send(params);
}
java servlet中直接获取
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
String str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
获取使用request.getParamnter("000");
执行相应的操作.
如果想返回数据 out.write("...xml文本格式.....");

你可能感兴趣的:(java,html,xml,servlet)