aspose file tools*
The moose likes Spring and the fly likes Spring Path Variable Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Path Variable Issue" Watch "Spring Path Variable Issue" New topic
Author

Spring Path Variable Issue

Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
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.


Ram Parashar
http://doinfinite.com
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

Do you meant to say that with extra / it is not working?


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
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

Joined: Jul 26, 2011
Posts: 461
    
    4
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:
 
 
subject: Spring Path Variable Issue