Several ways to get the request object in SpringMVC
1. The easiest way (annotation method)
1 2 |
|
2. The most troublesome method
a. Configure a listener in web.xml
<listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener>
b. It can be used in the program later
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
3. The most direct method
1 |
|
How to get a request object in Struts2
HttpServletRequest request = ServletActionContext.getRequest();