File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Path Variable Issue" Watch "Spring Path Variable Issue" New topic

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/ but not /api/users/, not able to figure out what exactly is the reason.

Ram Parashar
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1850

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

Krishna Srinivasan
OCAJP 7/8 Exam, 400+ OCPJP Mock Questions
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
This one is working



is not and throwing 406 exception.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
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:
I agree. Here's the link:
subject: Spring Path Variable Issue
It's not a secret anymore!