The first type, parameter
@RequestMapping ("/test") @ResponseBodypublic void Savetest (HttpServletRequest req, HttpServletResponse resp) {}
The second type, annotations
@Autowired private HttpServletRequest request;
Third, context acquisition
1. Configure the Listener in Web. xml
<listener> <listener-class>org.springframework.web.context.request.requestcontextlistener</ Listener-class></listener>
2, the use of the program
HttpServletRequest req = ((servletrequestattributes) requestcontextholder.getrequestattributes ()). GetRequest (); HttpServletResponse resp = ((servletwebrequest) requestcontextholder.getrequestattributes ()). GetResponse ();
Use according to your preferences
Recommendation of the third
This article is from the "yyyyyyyyyyyyyyyyyyyy" blog, make sure to keep this source http://765133133.blog.51cto.com/8956560/1954465
java-spring-Getting Request,response objects