From a789bf2f1ef68afe81817c9b679f51a7e6d6879c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 20 Oct 2009 21:56:22 +0000 Subject: [PATCH] Polishing the MVC sections of the reference manual. --- spring-framework-reference/src/mvc.xml | 43 +++++++++---------------- spring-framework-reference/src/view.xml | 30 ++++++++--------- 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 083b57ca5eb..6952dc38d69 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -2559,15 +2559,6 @@ background=/themes/cool/img/coolBg.jpg <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> - <!-- one of the properties available; the maximum file size in bytes --> - <property name="maxUploadSize" value="100000"/> -</bean> - - This example uses the - CosMultipartResolver: - - <bean id="multipartResolver" class="org.springframework.web.multipart.cos.CosMultipartResolver"> - <!-- one of the properties available; the maximum file size in bytes --> <property name="maxUploadSize" value="100000"/> </bean> @@ -2575,9 +2566,7 @@ background=/themes/cool/img/coolBg.jpg Of course you also need to put the appropriate jars in your classpath for the multipart resolver to work. In the case of the CommonsMultipartResolver, you need to use - commons-fileupload.jar; in the case of the - CosMultipartResolver, use - cos.jar. + commons-fileupload.jar. When the Spring DispatcherServlet detects a multi-part request, it activates the resolver that has been declared in @@ -2596,7 +2585,7 @@ background=/themes/cool/img/coolBg.jpg After the MultipartResolver completes its job, the request is processed like any other. To use it, you create a form with an upload field (see immediately below) that will - allow the user to upload a form, then let Spring bind the file onto your + allow the user to upload a form. Then let Spring bind the file onto your form (backing object). <html> @@ -2660,25 +2649,25 @@ background=/themes/cool/img/coolBg.jpg protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException, IOException { - // cast the bean + // cast the bean FileUploadBean bean = (FileUploadBean) command; - let's see if there's content there + // let's see if there's content there byte[] file = bean.getFile(); if (file == null) { - // hmm, that's strange, the user did not upload anything + // hmm, that's strange, the user did not upload anything } - // well, let's do nothing with the bean for now and return + // well, let's do nothing with the bean for now and return return super.onSubmit(request, response, command, errors); } protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws ServletException { - // to actually be able to convert Multipart instance to byte[] - // we have to register a custom editor + // to actually be able to convert Multipart instance to byte[] + // we have to register a custom editor binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); - // now Spring knows how to handle multipart object and convert them + // now Spring knows how to handle multipart objects and convert them } } @@ -2711,16 +2700,16 @@ public class FileUploadBean { protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException, IOException { - // cast the bean + // cast the bean FileUploadBean bean = (FileUploadBean) command; - let's see if there's content there + // let's see if there's content there String file = bean.getFile(); if (file == null) { - // hmm, that's strange, the user did not upload anything + // hmm, that's strange, the user did not upload anything } - // well, let's do nothing with the bean for now and return + // well, let's do nothing with the bean for now and return return super.onSubmit(request, response, command, errors); } @@ -2762,16 +2751,16 @@ public class FileUploadBean { protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws ServletException, IOException { - // cast the bean + // cast the bean FileUploadBean bean = (FileUploadBean) command; let's see if there's content there MultipartFile file = bean.getFile(); if (file == null) { - // hmm, that's strange, the user did not upload anything + // hmm, that's strange, the user did not upload anything } - // well, let's do nothing with the bean for now and return + // well, let's do nothing with the bean for now and return return super.onSubmit(request, response, command, errors); } } diff --git a/spring-framework-reference/src/view.xml b/spring-framework-reference/src/view.xml index 1e8c7adcbbd..c63142656cd 100644 --- a/spring-framework-reference/src/view.xml +++ b/spring-framework-reference/src/view.xml @@ -72,7 +72,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp When using the Java Standard Tag Library you must use a special view class, the JstlView, as JSTL needs some - preparation before things such as the i18N features will work. + preparation before things such as the I18N features will work.
@@ -86,8 +86,8 @@ productList.url=/WEB-INF/jsp/productlist.jsp escaping of characters. The tag library descriptor (TLD) is included in the spring.jar as well in the distribution - itself. Further information about the individual tags can be found in + class="libraryfile">org.springframework.web.servlet-3.0.0.RELEASE.jar. + Further information about the individual tags can be found in the appendix entitled .
@@ -115,7 +115,8 @@ productList.url=/WEB-INF/jsp/productlist.jsp Configuration The form tag library comes bundled in - spring.jar. The library descriptor is called + org.springframework.web.servlet-3.0.0.RC1.jar. + The library descriptor is called spring-form.tld. To use the tags from this library, add the following directive @@ -813,7 +814,7 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) { dependencies included in your project. The following is the list of dependencies you need. - + Tiles version 2.0.4 or higher @@ -829,10 +830,8 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) { Commons Logging - + - These dependencies are all available in the Spring - distribution.
@@ -910,12 +909,12 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp As you can see, when using the ResourceBundleViewResolver, you can easily mix different view technologies. -
- Note that the TilesView class for Tiles 2 - supports JSTL (the JSP Standard Tag Library) out of the box, whereas - there is a separate TilesJstlView subclass in the - Tiles 1.x support. + Note that the TilesView class for Tiles 2 + supports JSTL (the JSP Standard Tag Library) out of the box, whereas + there is a separate TilesJstlView subclass in the + Tiles 1.x support. +
<classname>SimpleSpringPreparerFactory</classname> and @@ -990,10 +989,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp found by a Java EE server and added to the classpath for your application. It is of course assumed that you already have the <filename class="libraryfile">spring.jar</filename> in your <filename - class="directory">'WEB-INF/lib'</filename> directory too! The latest - stable Velocity, FreeMarker and Commons Collections jars are supplied - with the Spring framework and can be copied from the relevant <filename - class="libraryfile">/lib/</filename> sub-directories. If you make use of + class="directory">'WEB-INF/lib'</filename> directory too! If you make use of Spring's 'dateToolAttribute' or 'numberToolAttribute' in your Velocity views, you will also need to include the <filename class="libraryfile">velocity-tools-generic-1.x.jar</filename></para>