2010年6月3日 星期四

Flex的HttpSession的簡單示例

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:



com.test.GETSESSION
application


PS2:返回的OBJECT如果想要與AS3的OBJECT轉化的話這個類要實現序列化(Serializable),還必須有get set方法, maybe flex access to the object with this javacode


mxml:


http://www.adobe.com/2006/mxml" layout="absolute">




http://bjutren.spaces.live.com/");
}
]]>



source:

http://bjutren.spaces.live.com/blog/cns!B6940F2EF5F948FC!162.entry?sa=588346105

reference:

Flex Remote Object中直接使用HttpSession的方法

http://blog.csdn.net/kerry365/archive/2005/09/23/488217.aspx

沒有留言: