For developing the web services, REST has become a proper way for enhancing the web services and when Java comes into the picture there are lots of frameworks and libraries that are present for instance JAX-RS, Jersey, Restlet, Apache CFX, RESTEasy etc. RESTful web services are enhanced and consumed by using the Spring MVC which helps few details for making the best use of them and fastly increase the RESTful services that are always needed by you:
1) There are various HTTP methods and here is where a controller can handle requests in Spring MVC which is considered as the backbone of RESTful web services. GET method, for instance, can be achieved by performing the read operation and POST method can enhance the resources. All the HTTP methods can be controlled by handling the requests in Spring MVC which is the support for RESTful web services. For instance, GET method can be handled by performing the read operation, POST method for developing the resources and PUT and DELETE method is used for removing the resources from the server.
2) The data representation is quite significant in case of REST and here is why Spring MVC permits you to bypass View-based rendering completely by using lots of HttpMessgeConverte implementations. By using this two you can directly send a response to client e.g. the resource clients wants and also in the format they need.
3) A dedicated annotation is included by Spring 4.0 for making the RESTful web services development quite simpler. With the help of controller class if you annotate the controller @RestController rather than @Controller then Spring applied message conversations with various methods in the controller. This implies that there is no requirement for annotating each method with the ResponseBody annotation.
4) One of the significant between a normal web application and web services that REST pass resource identifier data within URI. If you are aware that we choose @RequestParam for acquiring the value fo those query parameter but there is nothing to worry, Spring MVC also offers data extraction from URL. It permits the controller for handling requests for URLs that are parameterized.
Read More : Top 4 Java Web Frameworks Built For Scalability
5) Representation is another aspect for RESTful web services with the same resource for representing various formats eg: HTML., JSON, XML, etc. The file extension of Accept header or requests can be looked by the ContentNegotiatingViewResolver for instance.
6) For converting the response to the format client which is the same as ResponseBody annotation for formatting client needs, Spring MVC also offers @RequestBody annotation which is used by HTTPMETHODCONVERTER for converting HTTP data inside the Java Objects passed within the method of controller’s handler.
Reference site: Javarevisited