Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of @Context annotation from JAX-RS in Spring to inject HttpServletRequest?

In JAX-RS resource classes we can use

@Context
private HttpServletRequest request;

to be able to access details from the HTTP request.

What is the equivalent of the above line in Spring Boot? I don't want to add HttpServletRequest as argument in each method of my REST controller class.

like image 721
martin kimani Avatar asked Oct 17 '25 06:10

martin kimani


1 Answers

Have you tried @Autowired?

@Autowired
private HttpServletRequest request;
like image 150
cassiomolin Avatar answered Oct 19 '25 21:10

cassiomolin