Spring has long had some of the ingredients needed for exposing Rest resources.
Starting with version 3.0, however, Spring began adding enhancements to Spring MVC
to provide first-class REST support.
Spring supports the creation of REST resources in the following ways:
Starting with version 3.0, however, Spring began adding enhancements to Spring MVC
to provide first-class REST support.
Spring supports the creation of REST resources in the following ways:
- Controllers can handle requests for all HTTP methods, including the four primary REST methods: GET, PUT, DELETE, and POST. Spring 3.2 and higher also supports the PATCH method.
- The @PathVariable annotation enables controllers to handle requests for parameterized URLs (URLs that have variable input as part of their path).
- Resources can be represented in a variety of ways using Spring views and view resolvers, including View implementations for rendering model data as XML,JSON, Atom, and RSS.
- The representation best suited for the client can be chosen using Content Negotiating ViewResolver
- View-based rendering can be bypassed altogether using the @ResponseBody annotation and various HttpMethodConverter implementations.
- Similarly, the @RequestBody annotation, along with HttpMethodConverter
implementations, can convert inbound HTTP data into Java objects passed in to
a controller’s handler methods. - Spring applications can consume REST resources using RestTemplate.