如何在java普通类中获取request
2017-01-08
展开全部
框架都会提供方法来获取的,如下内容:
在spring的普通类中:
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
request.getSession();
在Struts的普通类中:
HttpServletRequest request = ServletActionContext.getRequest();
request.getSession();
在spring的普通类中:
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
request.getSession();
在Struts的普通类中:
HttpServletRequest request = ServletActionContext.getRequest();
request.getSession();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询