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/explo

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

相关文章
|
4天前
|
JavaScript
浏览器插件crx文件--JS混淆与解密
浏览器插件crx文件--JS混淆与解密
11 0
|
1月前
|
开发框架 前端开发 算法
【Qt App 编译 】Qt Cmake 资源文件的加载:如何使用 CMakeLists.txt 文件和资源文件
【Qt App 编译 】Qt Cmake 资源文件的加载:如何使用 CMakeLists.txt 文件和资源文件
29 0
|
8月前
ant-upload上传成功
ant-upload上传成功
51 0
|
8月前
|
JavaScript
.ts 文件编译成 .js 文件,以及 VSCode 自动编译配置
.ts 文件编译成 .js 文件,以及 VSCode 自动编译配置
330 0
|
11月前
|
JavaScript 前端开发 数据安全/隐私保护
[✔️]cocos creator 2.x无法加载.js后缀的npm包
[✔️]cocos creator 2.x无法加载.js后缀的npm包
156 0
|
前端开发 JavaScript Java
IDEA maven web项目无法加载css,js,image等一系列路径问题
我们大二班级 刚刚学习maven 控制台输出 和mybatis的时候我提前进入学习的路程自己摸索 maven web开发 遇到了各种配置环境还有运行报错一大堆的问题, 前面的问题都属于环境配置看我之前的博客吧 这里主要讲解路径问题 步入:很多新手按照之前的步骤 部署网站的时候 发现css,js,image,还有各种有关路径的引入都无法显示,因为这些静态资源很有可能被spring拦截 方案:必须在web.xml文件中设置其为可加载资源
IDEA maven web项目无法加载css,js,image等一系列路径问题
|
JavaScript iOS开发
Xcode编译WebApps找不到js的错误解决办法
Xcode编译WebApps找不到js的错误解决办法
109 0
|
前端开发 JavaScript Java
关于富文本编辑器—UEditor(java版)的使用,以及如何将UEditor的文件/图片上传路径改成绝对路径
突然发现好久没写博客了,感觉变懒了,是要让自己养成经常写文章的习惯才行。既可以分享自己的所学,和所想,和大家一起讨论,发现自己的不足的问题。 大家可能经常会用到富文本编辑器,今天我要说的是UEditor的使用,这是一个简单易用的开源富文本编辑器。
3269 0
Window bat rar压缩脚本
rar a MyData.rar -m5 -s -r D:\test\*.* E:\data\*.* E:\mydata\*.*
1102 0