flex和spring security搭建的时候遇到一个问题,在发送http请求的时候需要给服务器发送sessionid要不然你只能请求到security没有拦截的login页面
var httpService:HTTPService=new HTTPService;
httpService.url=Constants.SERVER + this._url;
httpService.method=this._method;
httpService.useProxy=false;
httpService.requestTimeout = 10;
httpService.headers["JSESSIONID"]=Constants.SESSIONID;
if(!isLogin)
{
if("GET" == httpService.method)
httpService.contentType="application/x-www-form-urlencoded";
else
httpService.contentType="application/json";
}
else
{
httpService.contentType="application/x-www-form-urlencoded";
}
httpService.addEventListener("result", resultHandler);
httpService.addEventListener("fault",faultHandler);
httpService.send(params);
// 上面是发送sessionid
// 获取sessionid,请求登录成功后,http请求的根据http协议会返回一个sessionid这里就可以获得到
private function resultHandler(event:ResultEvent):void
{
var jsessionId:String = event.currentTarget.headers["JSESSIONID"];
}