Flex开发中使用Ant编译.mxml成.swf后,在.swf里使用Session的解决方法

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的处理

http://livedocs.macromedia.com/flex/15/flex_docs_en/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flex_Documentation&file=00002247.htm

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了。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值