DWR应用中如何取得session
展开全部
具体取得session的代码可参考以下
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import uk.ltd.getahead.dwr.ExecutionContext;
public class RequestHelp {
static HttpServletRequest request=ExecutionContext.get().getHttpServletRequest();
//取得request对象实例
public static HttpServletRequest getRequest(){if(request==null){request=ExecutionContext.get().getHttpServletRequest();}return request;}
//取得session对象实例
public static HttpSession getReqSession(){return getRequest().getSession();}}二、在dwr2.0后可以通过uk.ltd.getahead.dwr.WebContextFactory的Web上下文工厂类取的上下文环境。从而取得request对象实例和session对象实例等。
import uk.ltd.getahead.dwr.WebContext;
import uk.ltd.getahead.dwr.WebContextFactory;
//取得request对象实例
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import uk.ltd.getahead.dwr.ExecutionContext;
public class RequestHelp {
static HttpServletRequest request=ExecutionContext.get().getHttpServletRequest();
//取得request对象实例
public static HttpServletRequest getRequest(){if(request==null){request=ExecutionContext.get().getHttpServletRequest();}return request;}
//取得session对象实例
public static HttpSession getReqSession(){return getRequest().getSession();}}二、在dwr2.0后可以通过uk.ltd.getahead.dwr.WebContextFactory的Web上下文工厂类取的上下文环境。从而取得request对象实例和session对象实例等。
import uk.ltd.getahead.dwr.WebContext;
import uk.ltd.getahead.dwr.WebContextFactory;
//取得request对象实例
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询