阅读更多
Flex开发中使用Ant编译.mxml成.swf后,在.swf里使用Session的解决方法
http://iamin.blogdriver.com/iamin/1176113.html
Flex Remote Object中直接使用HttpSession的方法在Flex Samples里有Session的操作使用例子: http://localhost:8080/samples/explorer/misc/ServerSessionDemo.mxml 但是,使用mxmlc编译.mxml成.swf后,在.swf里是没有办法使用Session的
解决办法:可以通过RemoteObject的通讯方式来进行Session的处理
Working with session data A Java object that you call using the <remoteobject></remoteobject>tag has access to request, response, and servlet data. From within a Java object, you can call the following methods:
Method Description flashgateway.Gateway.getHttpRequest()
Returns the HttpServletRequest object for the current request. Macromedia recommends that you access session data and other request data through the getHttpRequest() method.
flashgateway.Gateway.getHttpResponse()
Returns the HttpServletResponse object for the current request.
flashgateway.Gateway.getServletConfig()
Returns the ServletConfig object for the calling servlet.
To compile calls with these methods in their classes, you must have the WEB-INF/lib/flashgateway.jar file in your classpath.
The following example shows code in a Java class for accessing a session attribute:
String fooAttrib = (String)flashgateway.Gateway.getHttpRequest().getSession(). getAttribute("attr1");
这样,.mxml文件经过编译成.swf后,照样可以进行使用Session了。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有