- <listener>
- <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
- </listener>
- public static HttpServletRequest getRequest(){
- HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
- return req;
- }
- public static HttpServletResponse getResponse(){
- HttpServletResponse resp = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();
- return resp;
- }
- @Autowired
- private HttpSession session;
- @Autowired
- private HttpServletRequest request;
原文地址:https://www.cnblogs.com/liangbo-/p/8885498.html
时间: 2024-10-10 10:49:05