在java中如何在非servlet的普通类中获取request、response、session
原文:http://blog.csdn.net/u012255097/article/details/53092628
在spring的普通类中:
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
request.getSession();
在Struts的普通类中:
HttpServletRequest request = ServletActionContext.getRequest();
request.getSession();
HttpServletResponse response =ServletActionContext.getResponse();
看完打开支付宝扫一扫领个红包吧!