Search This Blog

Sunday, October 13, 2013

Spring REST - access HTTP header data on the server side

This is an example of a simple REST call on the server side;

The call looks like the following:

[GET] http://localhost:8080/rest/user/getUser/userNameABC
Accept: application/json
Authorization: 123456

@RequestMapping(value="/getUser/{login}", method = RequestMethod.GET, produces="application/json", headers="Accept=application/json")
public User getUser(
   @RequestHeader(value = "Authorization", required = true) String authorization,
   @PathVariable String login) {
     if (login.isEmpty())
        return null;


The @RequestHeader accesses for us data in the header. We can also get the Accept parameter by adding:

@RequestHeader(value = "Accept") String acceptString

1 comment:

  1. I have to say this could all have been avoided if your rolex replica uk did not accept orders and take payment for items you don't really have for sale. I will send an enquiry as to the stock availability by return to this email when I return from holiday. Please be kind enough to rolex replica sale me when the refund is acted. No shop will do a repair to replica watches in the UK. They will confiscate the watch and destroy it. Could you please refund my account as rolex replica sale is faulty. Please advice if you need me to post the faulty watch back to you or do you want me to throw it away in the rubbish bin. Could you send a replacement that has been tested and is fault free. If this is not possible could you please issue a full refund. As stated earlier this was to be replica watches sale and am very disappointed upon receiving the faulty watch.


If you like this post, please leave a comment :)