package com.boco.eoms.flex.service

{

import com.boco.eoms.flex.service.components.LoadingMask;


public class RequestServer

{

import flash.net.URLVariables;

import mx.controls.Alert;

import mx.rpc.http.HTTPService;

private var service:HTTPService;

public function RequestServer()

{

super();

}

private function init(fn:Function,faultFn:Function):void{

if(this.service == null){

service=new HTTPService();

service.method="POST";

service.useProxy=false;

service.resultFormat=HTTPService.RESULT_FORMAT_XML;

service.addEventListener("result", fn);

service.addEventListener("fault", faultFn);

}

}

/**

* 调用服务器

*/

public function queryChartPage(ip:String,port:String,path:String,

monitorType:String,selectCity:String,selectCityId:String,

selectIndicator:String,selectIndicatorId:String,selectChart:String,

fn:Function,faultFn:Function):void{

LoadingMask.show();

var url:String = "http://"+ip+":"+port+path+"/eomsSheetMonitorThreeController/queryChartPage.do";

//Alert.show(url);

this.init(fn,faultFn);//初始化httpService

service.url=url;

var params:URLVariables = new URLVariables();

//params.method = "monitorView";

params.monitorType = monitorType;

params.selectCity = httpEncoding(selectCity);

params.selectCityId = httpEncoding(selectCityId);

params.selectIndicator = httpEncoding(selectIndicator);

params.selectIndicatorId=httpEncoding(selectIndicatorId);

params.selectChart = httpEncoding(selectChart);

service.send(params);  

}

//对提交给后台的参数进行UTF-8的编码处理

private function httpEncoding(param:String):String{

return encodeURIComponent(param);

}


}



java后台代码接收参数

 //处理post方式乱码

        request.setCharacterEncoding("utf-8");

        

String selectCity=URLDecoder.decode(request.getParameter("selectCity"),"utf-8");//选中的地市名

String selectCityId=URLDecoder.decode(request.getParameter("selectCityId"),"utf-8");//选中的地市ID

String selectIndicator=URLDecoder.decode(request.getParameter("selectIndicator"),"utf-8");//选中的指标名

String selectIndicatorId=URLDecoder.decode(request.getParameter("selectIndicatorId"),"utf-8");//选中的指标ID

String selectChart=URLDecoder.decode(request.getParameter("selectChart"),"utf-8");//选中的图形