In this section, you will learn about some of the aspects of building RESTful web APIs using Spring. Recall, in Chapter 1, Introduction to Spring Web Framework, you learned how DispatcherServlet
is used to dispatch the incoming HTTP requests to the registered handlers, such as web UI controllers, for processing the request and providing convenient mapping, along with exception handling facilities. These controllers provide one or more methods to process incoming requests based on the handler mappings. It is these controllers that are used to expose REST APIs.
The key difference between a RESTful web service controller and the traditional web UI controller is the manner in which the HTTP response body is created and returned as a response. A traditional MVC controller depends upon the ViewResolvers
to perform server-side rendering of the response data to HTML. RESTful web API controllers return a domain object representing the resource instead of a view. These...