现在的位置: 首页 > 综合 > 正文

Flex+J2EE获取FlexSession的方法

2013年06月23日 ⁄ 综合 ⁄ 共 1329字 ⁄ 字号 评论关闭
 

转:http://hi.baidu.com/wowodo/blog/item/dada4a901203bb99a977a495.html

官方:http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcds/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=messaging_framework_6.html

-------web.xml文件
<listener>
        <listener-class>flex.messaging.HttpFlexSession</listener-class>
    </listener>

------Java代码
public class GetSeesion {
 /**
  * 设置session
  * */
 public void setSession(String name,String value){
  FlexContext.getFlexSession().setAttribute(name, value);
 }
 //获得session
 public String getSession(String name){
  String userid=(String) FlexContext.getFlexSession().getAttribute(name);
  return userid;
 }
}

-------在remoting-config.xml中加入
<!-- 用户信息保存到session中 -->
 <destination id="sessionBiz">
        <properties>
            <source>com.ssfx.util.GetSeesion</source>
            <scope>application</scope>
        </properties>
    </destination>

-------使用session
<mx:RemoteObject id="sBiz" destination="sessionBiz" showBusyCursor="true">
  <mx:method name="setSession"/>
 <mx:method name="getSession" result="sessionHandle(event)"/>
 </mx:RemoteObject>
<script>
 <![CDATA[
  sBiz.setSession("userId",txtUserId.text);
  sBiz.getSession("userId");
  /* 获得后台session处理函数 */ 
   private function sessionHandle(event:ResultEvent):void{
    var userCode=String(event.result);
    this.addPlanMess(userCode);
   }
 ]]>
</script>

 

ps:先记录下解决办法,有空再试一试可否成功。

抱歉!评论已关闭.