Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Path Variable Issue

 
Ram Para
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have defined a rest request Handler like this

@RequestMapping(value="/{userId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML)
public @ResponseBody
Domain getUserProfile(@PathVariable String userId) throws XmlException{


It works like /api/users/abc@xyz.com/ but not /api/users/abc@xyz.com, not able to figure out what exactly is the reason.
 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you meant to say that with extra / it is not working?
 
Ram Para
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one is working

/api/users/abc@xyz.com/


and

/api/users/abc@xyz.com
is not and throwing 406 exception.
 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpMediaTypeNotAcceptableException: 406 Not Acceptable


is not the same as:

NoSuchRequestHandlingMethodException 404 Not Found
HttpRequestMethodNotSupportedException 405 Method not Allowed
HttpMediaTypeNotSupportedException 415 Unsupported Media Type

Have a check again, use TCP/IP mon to see what client send up to the server:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic