|
|
|
|
|
|
95
|
|
95
|
|
|
96
|
The implementation of the method body creates and returns a new `Greeting` object with `id` and `content` attributes based on the next value from the `counter`, and formats the given `name` by using the greeting `template`.
|
96
|
The implementation of the method body creates and returns a new `Greeting` object with `id` and `content` attributes based on the next value from the `counter`, and formats the given `name` by using the greeting `template`.
|
|
97
|
|
97
|
|
|
98
|
-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 (such as [JSP][u-jsp]) 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.
|
|
|
|
|
|
98
|
+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][u-view-templates] 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.
|
|
99
|
|
99
|
|
|
100
|
To accomplish this, the [`@ResponseBody`][] annotation on the `greeting()` method tells Spring MVC that it does not need to render the greeting object through a server-side view layer, but that instead that the greeting object returned _is_ the response body, and should be written out directly.
|
100
|
To accomplish this, the [`@ResponseBody`][] annotation on the `greeting()` method tells Spring MVC that it does not need to render the greeting object through a server-side view layer, but that instead that the greeting object returned _is_ the response body, and should be written out directly.
|
|
101
|
|
101
|
|
|
|
|
|
|
|
155
|
|
155
|
|
|
156
|
[u-rest]: /understanding/REST
|
156
|
[u-rest]: /understanding/REST
|
|
157
|
[u-json]: /understanding/JSON
|
157
|
[u-json]: /understanding/JSON
|
|
158
|
-[u-jsp]: /understanding/JSP
|
|
|
|
|
|
158
|
+[u-view-templates]: /understanding/view-templates
|
|
159
|
[jackson]: http://wiki.fasterxml.com/JacksonHome
|
159
|
[jackson]: http://wiki.fasterxml.com/JacksonHome
|
|
160
|
[u-war]: /understanding/WAR
|
160
|
[u-war]: /understanding/WAR
|
|
161
|
[u-tomcat]: /understanding/Tomcat
|
161
|
[u-tomcat]: /understanding/Tomcat
|