<para>Spring's view resolution is extremely flexible. A
<interfacename>Controller</interfacename> implementation can even write
directly to the response stream. Typically, a
<classname>ModelAndView</classname> instance consists of a view name and a
model <interfacename>Map</interfacename>, which contains bean names and
corresponding objects such as a command or form, which contain reference
data. View name resolution is highly configurable, through bean names, a
properties file, or your own <interfacename>ViewResolver</interfacename>
implementation. The model (the M in MVC) is based on the
<interfacename>Controller</interfacename> is typically responsible for preparing
a model <classname>Map</classname> with data and selecting a view name but it
can also write directly to the response stream and complete the request.
View name resolution is highly configurable through file extension or Accept header
content type negotiation, through bean names, a properties file,
or even a custom <interfacename>ViewResolver</interfacename>
implementation. The model (the M in MVC) is a
<interfacename>Map</interfacename> interface, which allows for the
complete abstraction of the view technology. You can integrate directly
JSP, Velocity, or any other rendering technology. The model
<interfacename>Map</interfacename> is simply transformed into an
appropriate format, such as JSP request attributes or a Velocity template
JSP, Velocity, or render content types such as XML, JSON, Atom, and others.
The model <interfacename>Map</interfacename> is simply transformed into an
appropriate format, such as JSP request attributes, a Velocity template
model.</para>
<sectionid="mvc-features">
<title>Features of Spring Web MVC<!--I moved Features of Spring Web MVC before Pluggability of other MVC implementations. You want to highlight your own imp. first.--></title>
@ -261,14 +260,14 @@
@@ -261,14 +260,14 @@
<servlet-mapping>
<servlet-name>example</servlet-name>
<url-pattern>*.form</url-pattern>
<url-pattern>/example/*</url-pattern>
</servlet-mapping>
</web-app></programlisting>
<para>In the preceding example, all requests ending with
<literal>.form</literal> will be handled by the <literal>example</literal>
<classname>DispatcherServlet</classname>. This is only the first step in
<para>In the preceding example, all requests startig with
<literal>/example</literal> will be handled by the <classname>DispatcherServlet</classname>
instance named <literal>example</literal>. This is only the first step in
setting up Spring Web MVC. <!--The discussion below is a little vague about what you're doing, when you do it, and what you're accomplishing. --><!-- Is the next step shown in the next example screen?-->You
now need to configure the various beans used by the Spring Web MVC
framework (over and above the <classname>DispatcherServlet</classname>
@ -590,9 +589,10 @@
@@ -590,9 +589,10 @@
<tip>
<para>Available in the <linklinkend="new-in-3-samples">samples repository</link>,
the <emphasis>PetClinic</emphasis> web application leverages
the annotation support described in this section, in the context of
simple form processing.</para>
a number of web applications leverage the annotation support described in this section
including <emphasis>MvcShowcase</emphasis>, <emphasis>MvcAjax</emphasis>,
public String findOwner(<emphasisrole="bold">@PathVariable</emphasis>("ownerId") String theOwner, Model model) {
// implementation omitted
}</programlisting>
</tip>
<para>You can use multiple @PathVariable annotations to bind <!--specify: to bind *what* to multiple URI template variables? method parameter String ownerId?-->to
multiple URI Template variables:</para>
<para>A method can have multiple <interfacename>@PathVariable</interfacename> annotations:</para>
public void findPet(@PathVariable String ownerId, @PathVariable String petId, Model model) {
// implementation omitted
}
}</programlisting>
<tip>
<para>Although you can match to <emphasis>Content-Type</emphasis> and
<emphasis>Accept</emphasis> header values using media type wildcards (for example
<emphasis>"content-type=text/*"</emphasis> will match to <emphasis>"text/plain"</emphasis>
and <emphasis>"text/html"</emphasis>), it is recommended to use the
<emphasis>consumes</emphasis> and <emphasis>produces</emphasis> conditions
respectively instead. They are intended specifically for that purpose.
</para>
</tip>
<para>In the above example, the <methodname>addPet()</methodname>
method is only invoked when the <literal>content-type</literal>
matches the <literal>text/*</literal> pattern, for example,
<literal>text/xml</literal>.</para>
</section>
<sectionid="mvc-ann-requestmapping-arguments">
@ -1074,19 +1096,19 @@ public class RelativePathUriTemplateController {
@@ -1074,19 +1096,19 @@ public class RelativePathUriTemplateController {
</listitem>
<listitem>
<para>Command or form objects to bind parameters to: as bean
properties or fields, <!--What do you mean by *as bean properties or fields*, what does that refer to? Why do you have a colon? Don't get this line.--><!--*to bind parameters to* is awkward. Avoid slashes as with *command/form objects*. Do you mean command or form objects? Revise.-->with
<para>Command or form objects to bind request parameters to bean
properties (via setters) or directly to fields, with
customizable type conversion, depending on
<classname>@InitBinder</classname> methods and/or the
HandlerAdapter configuration. See the
<literal>webBindingInitializer</literal> property on
<classname>AnnotationMethodHandlerAdapter</classname>. Such
<classname>RequestMappingHandlerAdapter</classname>. Such
command objects along with their validation results will be
exposed as model attributes by default, using the non-qualified
command class name in property notation. <!--Who or what uses the non-qualified class name in property notation? Is this something you have to set up?-->For
example, "orderAddress" for type "mypackage.OrderAddress".
Specify a parameter-level<classname>ModelAttribute</classname>
annotation for declaring a specific model attribute name.</para>
exposed as model attributes by default, using the command class
class name - e.g. model attribute "orderAddress" for a command
object of type "some.package.OrderAddress".
The<classname>ModelAttribute</classname> annotation can be used
on a method argument to customize the model attribute name used.</para>