HttpServletRequest Authentication in Spring Controller

Say I have a Spring controller.

@RequestMappin("/path") public MyController { } 

As indicated, the default controller bulk is Singleton. I know that I can request an autwire request in the REQUEST beans area, however, if I try to audit, so

 @RequestMappin("/path") public MyController { @Autowired private HttpServletRequest request; } 

It still works, and for each request I get the corresponding request object. Does this mean that autwire works regardless of the request area or not?

+5
source share
2 answers

if it works, then spring does not enter exactly the HTTP request, but a proxy server. proxy delegate calls the current HTTP request

+4
source

You can get the HttpServletRequest object in each webservice method. For instance:

 @RequestMapping("/method") public void method(HttpServletRequest req) { // ... } 
+1
source

Source: https://habr.com/ru/post/1213836/


All Articles