diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml
index d88b9816166..8b2ce8e70e1 100644
--- a/spring-framework-reference/src/mvc.xml
+++ b/spring-framework-reference/src/mvc.xml
@@ -29,7 +29,7 @@
Some methods in the core classes of Spring Web MVC are marked
final. As a developer you cannot override these
methods to supply your own behavior. This has not been done arbitrarily, but
- specifically with this principal in mind.
+ specifically with this principal in mind.
For an explanation of this principle, refer to Expert
Spring Web MVC and Web Flow by Seth Ladd and others;
@@ -326,8 +326,8 @@
</web-app>
With the above servlet configuration in place, you
- will need to have a file called /WEB-INF/golfing-servlet.xml in your application;
+ will need to have a file called /WEB-INF/golfing-servlet.xml in your application;
this file will contain all of your Spring Web MVC-specific components
(beans). You can change the exact location of this configuration file
through a servlet initialization parameter (see below for details).
@@ -451,14 +451,14 @@
in the process to resolve the locale to use when processing the
request (rendering the view, preparing data, and so on). If you do not
need locale resolving, you do not need it.
-
+
The theme resolver is bound to the request to let elements such
as views determine which theme to use. If you do not use themes, you
can ignore it.
-
+
@@ -482,7 +482,7 @@
returned, (may be due to a preprocessor or postprocessor
intercepting the request, perhaps for security reasons), no view is
rendered, because the request could already have been fulfilled.
-
+
@@ -546,7 +546,7 @@
(using a comma as a delimiter) to support multiple contexts. In
case of multiple context locations with beans that are defined
twice, the latest location takes precedence.
-
+
@@ -586,7 +586,7 @@
PetClinic sample, a web application that leverages
the annotation support described in this section, in the context of
simple form processing. The PetClinic application
- resides in the samples/petclinic directory.
+ resides in the org.springframework.samples.petclinic module.
@@ -598,7 +598,7 @@ public class HelloWorldController {
@RequestMapping("/helloWorld")
public ModelAndView helloWorld() {
- ModelAndView mac = new ModelAndView();
+ ModelAndView mav = new ModelAndView();
mav.setViewName("helloWorld");
mav.addObject("message", "Hello World!");
return mav;
@@ -624,7 +624,7 @@ public class HelloWorldController {
indicates that a particular class serves the role of a
controller. Spring does not require you to extend
any controller base class or reference the Servlet API. However, you can
- still reference Servlet-specific features if you need to do so.
+ still reference Servlet-specific features if you need to.
The @Controller annotation acts as
a stereotype for the annotated class, indicating its role. The
@@ -638,7 +638,7 @@ public class HelloWorldController {
for autodetection, aligned with Spring general support for detecting
component classes in the classpath and auto-registering bean definitions
for them.
-
+
To enable autodetection of such annotated controllers, you add
component scanning to your configuration. Use the
spring-context schema as shown in the following XML
@@ -668,21 +668,20 @@ public class HelloWorldController {
You use the @RequestMapping
annotation to map URLs such as /appointments onto
- an entire class or a particular handler method. You can use it to
- annotate both a class and a method. Typically the class-level annotation
+ an entire class or a particular handler method. Typically the class-level annotation
maps a specific request path (or path pattern) onto a form controller,
with additional method-level annotations narrowing the primary mapping
for a specific HTTP method request method ("GET"/"POST") or specific
HTTP request parameters.
- The following example shows a controller from the PetClinic sample
- application that uses this annotation:
+ The following example shows a controller in a JSF application
+ that uses this annotation:@Controller
@RequestMapping("/appointments")
public class AppointmentsController {
- private AppointmentBook appointmentBook;
+ private final AppointmentBook appointmentBook;
@Autowired
public AppointmentsController(AppointmentBook appointmentBook) {
@@ -791,11 +790,11 @@ public class ClinicController {
variables.
- You use the @PathVariable method
+ Use the @PathVariable method
parameter annotation to indicate that a method parameter should be
bound to the value of a URI template variable.
- The following code snippet shows the use of a single
+ The following code snippet shows the usage of a single
@PathVariable in a controller
method:
@@ -815,21 +814,20 @@ public String findOwner(@PathVariable String ow
is bound to the method parameter String
ownerId.
-
+
The matching of method parameter names to URI Template variable
names can only be done if your code is compiled with debugging
enabled. If you do have not debugging enabled, you must specify the
name of the URI Template variable name in the @PathVariable annotation
- in order to bind the resovled value of the variable name to a
- method parameter. For example:
+ in order to bind the resolved value of the variable name to a
+ method parameter. For example:@RequestMapping(value="/owners/{ownerId}", method=RequestMethod.GET)
public String findOwner(@PathVariable("ownerId") String ownerId, Model model) {
// implementation omitted
-}
-
-
- so you can also use a controller method with the following
+}
+
+ You can also use a controller method with the following
signature:@RequestMapping(value="/owners/{ownerId}", method=RequestMethod.GET)
@@ -850,7 +848,7 @@ public String findPet(@PathVariable String owne
}
- The following code snippet shows the use of path variables on a
+ The following code snippet shows the usage of path variables on a
relative path, so that the findPet() method
will be invoked for /owners/42/pets/21, for
instance.
@@ -870,7 +868,7 @@ public class RelativePathUriTemplateController {
Method parameters that are decorated with the
@PathVariable annotation can be of
any simple type such as int, long,
- Date... Spring automatically converts to the appropriate type and
+ Date, etc. Spring automatically converts to the appropriate type and
throws a TypeMismatchException if the type is
not correct. You can further customize this conversion process by
customizing the data binder. See not supposed to be present in the request.Similarly, path mappings can be narrowed down through header
- conditions: @Controller
+ conditions:
+
+ @Controller
@RequestMapping("/owners/{ownerId}")
public class RelativePathUriTemplateController {
@@ -933,10 +933,11 @@ public class RelativePathUriTemplateController {
public void addPet(Pet pet, @PathVariable String ownerId) {
// implementation omitted
}
-}
- In the above example, the addPet is
- only invoked when the content-type is in the text/*
- range, for example, text/xml.
+}
+
+ In the above example, the addPet() method is
+ only invoked when the content-type matches the text/*
+ pattern, for example, text/xml.
@@ -945,13 +946,14 @@ public class RelativePathUriTemplateController {
Handler methods that are annotated with
@RequestMapping can have very flexible
signatures. They may have arguments of the following types, in
- arbitrary order. (except for validation results, which need to follow
- right after the corresponding command object, if desired):
+ arbitrary order (except for validation results, which need to follow
+ right after the corresponding command object, if desired):
+
- Request and/or response objects (Servlet API). Choose any
- specific request/response type, for example,
- ServletRequest /
+ Request or response objects (Servlet API). Choose any
+ specific request or response type, for example
+ ServletRequest or
HttpServletRequest.
@@ -964,7 +966,7 @@ public class RelativePathUriTemplateController {
Session access may not be thread-safe, in particular in
- a Servlet environment: Consider switching the
+ a Servlet environment. Consider setting the
AnnotationMethodHandlerAdapter's
"synchronizeOnSession" flag to "true" if multiple requests are
allowed to access a session concurrently.
@@ -1024,7 +1026,7 @@ public class RelativePathUriTemplateController {
@RequestBody annotated parameters
- for access to the request HTTP body. Parameter values are
+ for access to the HTTP request body. Parameter values are
converted to the declared method argument type using
HttpMessageConverters. See .
@@ -1047,7 +1049,7 @@ public class RelativePathUriTemplateController {
webBindingInitializer property on
AnnotationMethodHandlerAdapter. Such
command objects along with their validation results will be
- exposed as model attributes by default., using the non-qualified
+ exposed as model attributes by default, using the non-qualified
command class name in property notation. For
example, "orderAddress" for type "mypackage.OrderAddress".
Specify a parameter-level ModelAttribute
@@ -1059,7 +1061,7 @@ public class RelativePathUriTemplateController {
/
org.springframework.validation.BindingResult
validation results for a preceding command or form object (the
- immediately preceding argument).
+ immediately preceding method argument).
@@ -1109,7 +1111,7 @@ public class RelativePathUriTemplateController {
A String value that is interpreted
- as the view name, with the model implicitly determined through
+ as the logical view name, with the model implicitly determined through
command objects and @ModelAttribute annotated
reference data accessor methods. The handler method may also
programmatically enrich the model by declaring a
@@ -1139,7 +1141,7 @@ public class RelativePathUriTemplateController {
- Any other return type is considered as single model
+ Any other return type is considered to be a single model
attribute to be exposed to the view, using the attribute name
specified through @ModelAttribute at the
method level (or the default attribute name based on the return
@@ -1181,7 +1183,7 @@ public class EditPetForm {
@RequestParam's
required attribute to false
(e.g., @RequestParam(value="id",
- required="false")).
+ required=false)).
@@ -1197,7 +1199,7 @@ public void handle(@RequestBody String body, Writer writer) throws IOException {
writer.write(body);
}
- You convert the request body to the method argument by using a
+ You convert the request body to the method argument by using an
HttpMessageConverter.
HttpMessageConverter is responsible for
converting from the HTTP request message to an object and converting
@@ -1289,11 +1291,11 @@ public String helloWorld() {
return "Hello World";
}
- The example will result in the text Hello
+ The above example will result in the text Hello
World being written to the HTTP response stream.As with @RequestBody, Spring converts
- the returned object to a response body by using a
+ the returned object to a response body by using an
HttpMessageConverter. For more
information on these converters, see the previous section and Message Converters.
@@ -1311,10 +1313,10 @@ public String helloWorld() {
controller gets a reference to the object holding the data entered in
the form.
- You can also use the @ModelAttribute at
+ You can also use @ModelAttribute at
the method level to provide reference data for
- the model (see the populatePetTypes() method, as in
- the following example. For this usage the method signature can contain
+ the model (see the populatePetTypes() method in
+ the following example). For this usage the method signature can contain
the same types as documented previously for the
@RequestMapping annotation.
@@ -1337,27 +1339,28 @@ public String helloWorld() {
@SessionAttributes("pet")
public class EditPetForm {
- // ...
+ // ...
- @ModelAttribute("types")
- public Collection<PetType> populatePetTypes() {
- return this.clinic.getPetTypes();
- }
+ @ModelAttribute("types")
+ public Collection<PetType> populatePetTypes() {
+ return this.clinic.getPetTypes();
+ }
- @RequestMapping(method = RequestMethod.POST)
- public String processSubmit(
- @ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) {
+ @RequestMapping(method = RequestMethod.POST)
+ public String processSubmit(
+ @ModelAttribute("pet") Pet pet,
+ BindingResult result, SessionStatus status) {
- new PetValidator().validate(pet, result);
- if (result.hasErrors()) {
- return "petForm";
- }
- else {
- this.clinic.storePet(pet);
- status.setComplete();
- return "redirect:owner.do?ownerId=" + pet.getOwner().getId();
- }
- }
+ new PetValidator().validate(pet, result);
+ if (result.hasErrors()) {
+ return "petForm";
+ }
+ else {
+ this.clinic.storePet(pet);
+ status.setComplete();
+ return "redirect:owner.do?ownerId=" + pet.getOwner().getId();
+ }
+ }
}
@@ -1368,20 +1371,20 @@ public class EditPetForm {
The type-level @SessionAttributes
annotation declares session attributes used by a specific handler.
- This will typically list the names of model attributes which should be
+ This will typically list the names of model attributes or types of
+ model attributes which should be
transparently stored in the session or some conversational storage,
serving as form-backing beans between subsequent requests.The following code snippet shows the usage of this
- annotation:
+ annotation, specifying the model attribute name:
@Controller
@RequestMapping("/editPet.do")
@SessionAttributes("pet")
public class EditPetForm {
// ...
-}
-
+}
@@ -2197,15 +2200,15 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
@Controller
public class ContentController {
- private List<SampleContent> contentList = new ArrayList<SampleContent>();
+ private List<SampleContent> contentList = new ArrayList<SampleContent>();
- @RequestMapping(value="/content", method=RequestMethod.GET)
- public ModelAndView getContent() {
- ModelAndView mav = new ModelAndView();
- mav.setViewName("content");
- mav.addObject("sampleContentList", contentList);
- return mav;
- }
+ @RequestMapping(value="/content", method=RequestMethod.GET)
+ public ModelAndView getContent() {
+ ModelAndView mav = new ModelAndView();
+ mav.setViewName("content");
+ mav.addObject("sampleContentList", contentList);
+ return mav;
+ }
}
@@ -2934,20 +2937,20 @@ public class SimpleController {
AdminController maps to the
- /admin/* request
+ /admin/* request
URLCatalogController maps to the
- /catalog/*
+ /catalog/*
request URLIf you follow the convention of naming your
Controller implementations as
- xxxController, the
+ xxxController, the
ControllerClassNameHandlerMapping saves you the
tedium of defining and maintaining a potentially
looooong