Im using spring to build a Restful API and when I access the method below:
// get the entity in DB by using id number
@RequestMapping(value = "/{id:.+}", method = RequestMethod.GET)
public @ResponseBody
User getEmployee(@PathVariable("id") String email) {
User user=null;
System.out.println(email);
try {
user = dataServices.getEntityById(email);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(user.getNickname());
return user;
}
with this URL: http://localhost:8080/RestCrud/user/richard_johnson@sina.com
it gets 406 error:
I make sure I have added the
<mvc:annotation-driven />
Im also sure I added those jackson dependencies in pom.xml
********************edit*************************************
********************edit again*******************************
as you can see I did not restrict headers in the @RequestMapping annotation, so I dont think its an issue related to the header restriction.
Also, my url patterns are like:
http://localhost:8080/RestCrud/user/id
Ive tested the "list" http://localhost:8080/RestCrud/user/list
and it works, but the "id" path does not