How to get HTTP Request Header In Java

In this post , we will see how to get HTTP request header in java. Sometimes, you want to print request header values.
It is very simple to do it. You first need to get request object, then call getHeaderFields()  on it to get all request header values.

Spring MVC:

If you are using Spring MVC, then you can use @Autowired annotation to get request object in controller.

You will get output as below:

Add Comment