java如何在一个普通的类中获取request对象?
1个回答
展开全部
在spring的普通类中:
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();request.getSession();
在Struts的普通类中:
HttpServletRequest request = ServletActionContext.getRequest();request.getSession();
HttpServletResponse response =ServletActionContext.getResponse();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询