Here is my attempt to enhance the JPA/MVC/eclipse tutorial to implement a RESTful service. Why does this not work with this curl command? I get 404. Can someone help me correct this? Do I need to change my web.xml servlet mapping in web.xml? I've been experimenting with and nothing seems to work.
Thanks
Siegfried
Here is my web.xml fragment:
<servlet-mapping>
<servlet-name>spring</servlet-name>
<!-- <url-pattern>*.html</url-pattern> -->
<url-pattern>/</url-pattern>
</servlet-mapping>
Here is the curl command that causes a 404
curl -i -H "Accept: application/json" http://localhost:8080/Guestbook/user/siegfried -X GET
The logs say
Oct 11, 2013 11:21:28 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/Guestbook/user/siegfried] in DispatcherServlet with name 'spring'
Here is my controller.
@Controller
@RequestMapping("/api")
public class APIController{
@Autowired
private GuestDao guestDao;
@RequestMapping(value = "/user/{username}", method = org.springframework.web.bind.annotation.RequestMethod.GET,
headers = {"Accept=text/xml, application/json"})
public @org.springframework.web.bind.annotation.ResponseBody
Guest getGuest(@org.springframework.web.bind.annotation.PathVariable String username) {
return guestDao.getAllGuests().get(0);
}
}