The above example does not specify GET
vs. PUT
, POST
, and so forth, because @RequestMapping
maps all HTTP operations by default. Use @RequestMapping(method=GET)
to narrow this mapping.
2.返回结果的不同
A key difference between a traditional MVC controller and the RESTful web service controller above is the way that the HTTP response body is created. Rather than relying on a view technology to perform server-side rendering of the greeting data to HTML, this RESTful web service controller simply populates and returns a Greeting
object. The object data will be written directly to the HTTP response as JSON.