加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

blazeds flexContext flexSession用法

发布时间:2020-12-15 03:38:15 所属栏目:百科 来源:网络整理
导读:REMOTEOBJECT: package com.test; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import flex.messaging.*; public class GETSESSION { ??? public GETSESSION() { ??????? // TODO Auto-generated constructor st
REMOTEOBJECT:

package com.test;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import flex.messaging.*;
public class GETSESSION {

??? public GETSESSION() {
??????? // TODO Auto-generated constructor stub
??? }
???? public void setSession(String atr,Object val){
???????? HttpServletRequest request = FlexContext.getHttpRequest();
?????????? HttpSession session = request.getSession();
?????????? session.setAttribute(atr,val);
???? }
???? public Object getSession(String atr){
???????? HttpServletRequest request = FlexContext.getHttpRequest();
???????? HttpSession session = request.getSession();
???????? return session.getAttribute(atr);
???? }

}

PS1:我的remoting-config.xml:

<destination id="gethttpsession">
??? <properties>
??? <source>com.test.GETSESSION</source>
??? <scope>application</scope>
??? </properties>
??? </destination>

? PS2:返回的OBJECT如果想要与AS3的OBJECT转化的话这个类要实现序列化(Serializable),还必须有get set方法,maybe flex access to the object with this javacode

mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
??? <mx:RemoteObject id = "ro" destination="gethttpsession"? source="servlet">
?????????????? <mx:method name="getSession" result="getresult(event)"/>
??????? </mx:RemoteObject>
<mx:Script>
??????????????? <![CDATA[
??????????????? import mx.rpc.events.ResultEvent;
????????????? import mx.controls.Alert;
private function getresult(event:ResultEvent):void{
??????????????????? var cid:String = event.result as String;
?????????????????? Alert.show(cid);
??????????????????????????? }
???????????????? private function getsession():void{
??????????????????? ro.getSession("user");
??????????????????? //ro.addEventListener(ResultEvent.RESULT,getcomid);
??????????????????????????? }
??????????????????????????? private function init():void{
??????????????????????????????????? ro.setSession("user","http://bjutren.spaces.live.com/");
??????????????????????????? }
??????? ]]>
??????? </mx:Script>
<mx:Button x="125" y="89" label="setsession" click="init()"/>
<mx:Button x="125" y="119" label="getsession" click="getsession()"/>

</mx:Application>

http://fykyx521.iteye.com/blog/375706

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读