I am studying for the Spring Core certification and I have some doubt about how Spring MVC handle REST web service.
Reading the documentation I found this example:
@RequestMapping(value="/orders", method=RequestMethod.GET) public void listOrders(Model model) { // find all Orders and add them to the model } @RequestMapping(value="/orders", method=RequestMethod.POST) public void createOrder(HttpServletRequest request, Model model) { // process the order data from the request } Ok, it show 2 Spring MVC method (that I think should be declared into a controller class, is it true).
These methods both handle HTTP request towards the /orders resource (according to the REST style in which a resource is seen as a programming element that manages a kind of data and a state and provide processing on this kind).
In this case if the HTTP request toward the /orders is a GET it will be executed the listOrders() method that return the list of all objects but if the request toward the /orders is a POST it will perform the createOrder() that create a new order
So what exactly means, that using the method paramether of the @RequestMapping annotation I can handle the HttpRequest according to the RESTful style?