Flex使用navigateToURL发起POST请求时遇到的问题

在ActionScript里面请求后台Servlet,代码如下

 

var url:String = "https://aserver:7002/testServlet?action=someAction";
var u:URLRequest = new URLRequest(url);
u.method = URLRequestMethod.POST;
var data:URLVariables = new URLVariables();
data.var1 = "1";
data.var2 = "2";
u.data = data;
navigateToURL(u,"_blank");

 

结果在后台获取var1, var2 的值为null。经后台debug发现,request是GET方式。但是把Weblogic端口改为Http端口后一切正常。最后把navigateToURL(u,"_blank"); 改成 navigateToURL(u,"_self"); ,问题解决。具体原因下面的帖子有详细的分析,其中有一段分析的不错:

另外,这个问题在IE上面才有,chrom上没有问题。可能不同浏览器之间的实现也有关系?求正解。。。

 

I don't see any obvious reason on why your parameters are not forwarded to the secured page. However I tried this scenario on my setup and here is what I found out.

If you are using self-signed certificate then Internet Explorer will show you warning page that it does not trust the certificate and this warning is shown before actually invoking your secure URL. At this point IE actually has lost all the parameters that you have passed in your POST request. Firefox seems to be smart since it reposts the request once you confirm the certificate warning message and hence it works on Firefox. But IE8 does not repost the request for some reason.

So once you confirm the certificate warning just hit refresh on your Flex application IE window again and it should work this time, test it.

I don't have any solution to this but workaround is to trust and install the certificate into your browser permanently and it should solve your problem for now.

你可能感兴趣的:(Web,Flex)