在spring的普通类中:

HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();

request.getSession();

在Struts的普通类中:

HttpServletRequest request = ServletActionContext.getRequest();

request.getSession();

HttpServletResponse response =ServletActionContext.getResponse();

posted on 2019-04-08 17:50  java_zhao  阅读(15516)  评论(0编辑  收藏  举报