Reputation: 502
This is my simple Spring Rest Controller.
How can I get the Http request header information every time an URL is mapped to my controller?
@RestController
public class GreetingController {
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name") String name) {
// Here is where I want to get HTTP Request Header Info
return null;
}
Upvotes: 0
Views: 1502
Reputation: 30839
You can use @RequestHeader
as one of the arguments to the method to access it, e.g.:
public Greeting greeting(@RequestParam(value="name") String name,
@RequestHeader("Content-type") String contentType) {
Here's the javadoc for @RequestHeader
.
Upvotes: 5