<title>URI Templates In <interfacename>@RequestMapping</interfacename></title>
<title>URI Template Patterns</title>
<para><emphasis>URI templates</emphasis> can be used for convenient access to selected
segments of a URL in a <interfacename>@RequestMapping</interfacename> method.</para>
@ -875,7 +876,7 @@ public class RelativePathUriTemplateController {
@@ -875,7 +876,7 @@ public class RelativePathUriTemplateController {
</section>
<sectionid="mvc-ann-requestmapping-patterns">
<title>Path Patterns In <interfacename>@RequestMapping</interfacename></title>
<title>Path Patterns</title>
<para>In addition to URI templates, the
<interfacename>@RequestMapping</interfacename> annotation also
@ -887,7 +888,7 @@ public class RelativePathUriTemplateController {
@@ -887,7 +888,7 @@ public class RelativePathUriTemplateController {
</section>
<sectionid="mvc-ann-requestmapping-consumes">
<title>Consumable Media Types In <interfacename>@RequestMapping</interfacename></title>
<title>Consumable Media Types</title>
<para>
You can narrow the primary mapping by specifying a list of consumable media types.
The request will be matched only if the <emphasis>Content-Type</emphasis> request header
@ -913,7 +914,7 @@ public void addPet(@RequestBody Pet pet, Model model) {
@@ -913,7 +914,7 @@ public void addPet(@RequestBody Pet pet, Model model) {
</section>
<sectionid="mvc-ann-requestmapping-produces">
<title>Producible Media Types In <interfacename>@RequestMapping</interfacename></title>
<title>Producible Media Types</title>
<para>
You can narrow the primary mapping by specifying a list of producible media types.
The request will be matched only if the <emphasis>Accept</emphasis> request header
@ -943,7 +944,7 @@ public Pet getPet(@PathVariable String petId, Model model) {
@@ -943,7 +944,7 @@ public Pet getPet(@PathVariable String petId, Model model) {
<para>An <classname>@RequestMapping</classname> handler method can have a very flexible
signatures. The supported method arguments and return values are described in the
following section. Most arguments can be used in arbitrary order with the only
exception of <classname>BindingResult</classname> arguments. This is described
in the next section.
</para>
<sectionid="mvc-ann-arguments">
<title>Supported method argument types</title>
<para>The following are the supported method arguments:
<itemizedlist>
<listitem>
<para>Request or response objects (Servlet API). Choose any
specific request or response type, for example
@ -1151,9 +1158,13 @@ public String processSubmit(<emphasis role="bold">@ModelAttribute("pet") Pet pet
@@ -1151,9 +1158,13 @@ public String processSubmit(<emphasis role="bold">@ModelAttribute("pet") Pet pet
public String processSubmit(<emphasisrole="bold">@ModelAttribute("pet") Pet pet</emphasis>,
<emphasisrole="bold">BindingResult result</emphasis>, Model model) { … }</programlisting>
</example>
</section>
<sectionid="mvc-ann-return-types">
<title>Supported method return types</title>
<para>The following return types are supported for handler methods:
<itemizedlist>
<para>The following are the supported return types:
<itemizedlist>
<listitem>
<para>A <classname>ModelAndView</classname> object, with the
model implicitly enriched with command objects and the results
@ -1238,8 +1249,9 @@ public String processSubmit(<emphasis role="bold">@ModelAttribute("pet") Pet pet
@@ -1238,8 +1249,9 @@ public String processSubmit(<emphasis role="bold">@ModelAttribute("pet") Pet pet
objects and the results of <literal>@ModelAttribute</literal>
annotated reference data accessor methods.</para>
</listitem>
</itemizedlist></para>
</section>
</itemizedlist>
</para>
</section>
<sectionid="mvc-ann-requestparam">
<title>Binding request parameters to method parameters with
@ -1697,17 +1734,18 @@ public class MyFormController {
@@ -1697,17 +1734,18 @@ public class MyFormController {
<sectionid="mvc-handlermapping">
<title>Handler mappings</title>
<para>In previous versions of Spring, users were required to define
<interfacename>HandlerMapping</interfacename>s in the web application
<para>In previous versions of Spring, users were required to define one
or more <interfacename>HandlerMapping</interfacename> beans in the web application
context to map incoming web requests to appropriate handlers. With the
introduction of Spring 2.5, <!--IMPORTANT: Shouldn't that say Spring 3.0, since that's upcoming release? If you do mean 2.5, then first sentence should say in pre--><!--2.5 versions of Spring, not *previous*. Also in first sentence, I changed Spring MVC to Spring because it refers to a version.-->the
<classname>DispatcherServlet</classname> enables the
<classname>DefaultAnnotationHandlerMapping</classname>, which looks for
<interfacename>@RequestMapping</interfacename> annotations on
<interfacename>@Controllers</interfacename>. Typically, you do not need to
override this default mapping, unless you need to override the default
property values. These properties are:</para>
introduction of annotated controllers, you generally don't need to do
that because the <classname>RequestMappingHandlerMapping</classname>
automatically looks for <interfacename>@RequestMapping</interfacename>
annotations on all <interfacename>@Controller</interfacename> beans.
However, do keep in mind that all <classname>HandlerMapping</classname>
classes extending from <classname>AbstractHandlerMapping</classname>
have the following properties that you can use to customize their behavior:
</para>
<variablelist>
<varlistentry>
<term><literal>interceptors</literal></term>
@ -1754,7 +1792,7 @@ public class MyFormController {
@@ -1754,7 +1792,7 @@ public class MyFormController {
<varlistentry>
<term><literal>urlDecode</literal></term>
<listitem>
<para>Defaults to <literal>true</literal>, as of Spring 2.5. <!--OK, or do you mean 3.0?-->
<para>Defaults to <literal>true</literal>, as of Spring 2.5.
If you prefer to compare encoded paths, set this flag to
<literal>false</literal>. However, the
<interfacename>HttpServletRequest</interfacename> always exposes the
@ -1762,29 +1800,13 @@ public class MyFormController {
@@ -1762,29 +1800,13 @@ public class MyFormController {
not match when compared with encoded paths.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>lazyInitHandlers</literal></term>
<listitem>
<para>Allows lazy initialization of <emphasis>singleton</emphasis>
handlers (prototype handlers are always lazy-initialized). The
default value is <literal>false</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
<note>
<para>The <literal>alwaysUseFullPath</literal>,
<literal>urlDecode</literal>, and <literal>lazyInitHandlers</literal>
@ -1793,8 +1815,8 @@ public class MyFormController {
@@ -1793,8 +1815,8 @@ public class MyFormController {
<beans></programlisting>
<sectionid="mvc-handlermapping-interceptor">
<title>Intercepting requests - the
<interfacename>HandlerInterceptor</interfacename> interface<!--Revise head to delete dash. How should it read? Intercepting requests *through* the HandlerInterceptor Interface? *with*?--></title>
@ -1887,10 +1901,25 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
@@ -1887,10 +1901,25 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
that says, for example, you can only access the website during office
hours.</para>
<note>
<para>When using the <classname>RequestMappingHandlerMapping</classname>
the actual handler is an instance of <classname>HandlerMethod</classname>
which identifies the specific controller method that will be invoked.
</para>
</note>
<para>As you can see, the Spring adapter class
<classname>HandlerInterceptorAdapter</classname> makes it easier to
extend the <interfacename>HandlerInterceptor</interfacename>
interface.</para>
<tip>
<para>In the example above, the configured interceptor will apply to all
requests handled with annotated controller methods. If you want to narrow
down the URL paths to which an interceptor applies, you can use the MVC
namespace to do that. See <xreflinkend="mvc-annotation-driven"/>.</para>
</tip>
</section>
</section>
@ -2843,13 +2872,12 @@ public class FileUpoadController {
@@ -2843,13 +2872,12 @@ public class FileUpoadController {
with unexpected exceptions that occur during controller execution.
A <literal>HandlerExceptionResolver</literal> somewhat resembles the
exception mappings you can define in the web application descriptor
<literal>web.xml</literal>. However, they provide a more flexible way to
handle exceptions. They provide information about which handler was
do so. For example they provide information about which handler was
executing when the exception was thrown. Furthermore, a programmatic way
of handling exceptions gives you more options for responding
appropriately before the request is forwarded to another URL (the same
@ -2924,7 +2952,7 @@ public class FileUpoadController {
@@ -2924,7 +2952,7 @@ public class FileUpoadController {
</section>
<sectionid="mvc-ann-exceptionhandler">
<title><interfacename>@ExceptionHandler<!--Changed this from @ExceptionResolver because text and example say @ExceptionHandler.--></interfacename></title>
<interfacename>HandlerExceptionResolver</interfacename> interface is the
@ -3349,7 +3377,7 @@ public class SimpleController {
@@ -3349,7 +3377,7 @@ public class SimpleController {
<sectionid="mvc-annotation-driven">
<title>mvc:annotation-driven</title>
<para>
This tag registers the DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter beans that are required for Spring MVC to dispatch requests to @Controllers.
This tag registers the RequestMappingHandlerMapping and RequestMappingHandlerAdapter beans that are required for Spring MVC to dispatch requests to @Controllers.
The tag configures those two beans with sensible defaults based on what is present in your classpath.