发送从弯曲对象的Java Servlet [英] Send objects from flex to java servlet
问题描述
这是我的动作方法
var urlVars : URLVariables = new URLVariables();
urlVars.myname = byteArr;
var urlReq : URLRequest = new URLRequest('MyServlet');
urlReq.data = urlVars;
urlReq.method = 'post';
navigateToURL(urlReq, '_blank');
我如何接受她的字节数组的servlet?
How do I recieve the byte array on servlet ?
另外,byteArr以上来自Java端,
Also the byteArr above comes from java side,
byte[] byteArr = aMethodWhichReturnsaPDFByteArray();
HttpServletResponse response = FlexContext.getHttpResponse();
ServletOutputStream os = null;
try {
response.reset();
response.setContentType("application/pdf");
response.setContentLength(byteArr.length);
response.setHeader("Content-disposition",
"inline; filename=\"Report.pdf\"");
os = response.getOutputStream();
os.write(byteArr);
os.flush();
os.close();
以上方法没有奏效。
The above method did not work.
推荐答案
如果你坚持要送PARAMS这样,你在一个字符串再presentation最好的连接code中的字节数组。 <一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/Base64En$c$cr.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2"相对=nofollow> Base64的为例。在使用 commons- codeC 脱code它在Java端。
If you insist on sending the params this way, you'd better encode the byte array in a string representation. Base64 for example. On the java side used commons-codec to decode it.
Otherwise, see this article. It's a bit old, but still applies. Also see here
这篇关于发送从弯曲对象的Java Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!