From 713017aedc736354c8a9b31d09580deb33be0fa9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 29 Sep 2011 18:55:48 +0000 Subject: [PATCH] polishing and formatting --- spring-framework-reference/src/mvc.xml | 66 +++++++++++--------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index b9ca33f14e..e5fbd416ce 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -1825,8 +1825,7 @@ public class EditPetForm { HttpPutFormContentFilter, which can be configured in web.xml: - -<filter> + <filter> <filter-name>httpPutFormFilter</filter-name> <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> </filter> @@ -2468,7 +2467,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { <property name="location" value="/WEB-INF/views.xml"/> </bean> -<!— in views.xml --> +<!-- in views.xml --> <beans> <bean name="report" class="org.springframework.example.ReportExcelView"/> @@ -2710,8 +2709,9 @@ public String upload(...) { Views that can render an appropriate representation of the current resource regardless of the logical view name. The Accept header may include wild cards, for - example text/*, in which case a View whose - Content-Type was text/xml is a compatible match. + example text/*, in which case a + View whose Content-Type was + text/xml is a compatible match. To support the resolution of a view based on a file extension, use the ContentNegotiatingViewResolver bean property @@ -3323,8 +3323,7 @@ public class FileUpoadController { typically submit files and simple form fields, a programmatic client can also send more complex data of a specific content type — for example a multipart request with a file and second part with JSON formatted data: - -POST /someUrl + POST /someUrl Content-Type: multipart/mixed --edt7Tfrdusa7r3lNQc79vXuhIIMlatb7PQg7Vp @@ -3339,8 +3338,7 @@ Content-Transfer-Encoding: 8bit Content-Disposition: form-data; name="file-data"; filename="file.properties" Content-Type: text/xml Content-Transfer-Encoding: 8bit -... File Data ... - +... File Data ... You could access the part named "meta-data" with a @RequestParam("meta-data") String @@ -3615,14 +3613,12 @@ public class SimpleController { AdminController maps to the - /admin/* request - URL + /admin/* request URL CatalogController maps to the - /catalog/* - request URL + /catalog/* request URL @@ -3794,12 +3790,15 @@ public class SimpleController { } <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" - "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> -<beans> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- this bean with the well known name generates view names for us --> - <bean id="viewNameTranslator" class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/> + <bean id="viewNameTranslator" + class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/> <bean class="x.y.RegistrationController"> <!-- inject dependencies as necessary --> @@ -4044,16 +4043,14 @@ public class SimpleController { An example of registering an interceptor applied to all URL paths: - -<mvc:interceptors> + <mvc:interceptors> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /> </mvc:interceptors> An example of registering an interceptor limited to a specific URL path: - -<mvc:interceptors> + <mvc:interceptors> <mvc:interceptor> <mapping path="/secure/*"/> <bean class="org.example.SecurityInterceptor" /> @@ -4073,8 +4070,7 @@ public class SimpleController { An example of view-controller that forwards to a home page is shown below: - -<mvc:view-controller path="/" view-name="home"/> + <mvc:view-controller path="/" view-name="home"/>
@@ -4098,15 +4094,13 @@ public class SimpleController { directory within the web application root, the tag would be used as follows: - -<mvc:resources mapping="/resources/**" location="/public-resources/"/> + <mvc:resources mapping="/resources/**" location="/public-resources/"/> To serve these resources with a 1-year future expiration to ensure maximum use of the browser cache and a reduction in HTTP requests made by the browser: - -<mvc:resources mapping="/resources/**" location="/public-resources/" cache-period="31556926"/> + <mvc:resources mapping="/resources/**" location="/public-resources/" cache-period="31556926"/> The mapping attribute must be an Ant pattern that can be used by SimpleUrlHandlerMapping, and the @@ -4119,8 +4113,7 @@ public class SimpleController { /META-INF/public-web-resources/ in any jar on the classpath, the tag would be specified as: - -<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/public-web-resources/"/> + <mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/public-web-resources/"/> When serving resources that may change when a new version of the application is deployed, it is recommended that you incorporate a @@ -4148,20 +4141,17 @@ application.version=1.0.0 and then to make the properties file's values accessible to SpEL as a bean using the util:properties tag: - -<util:properties id="applicationProps" location="/WEB-INF/spring/application.properties"/> + <util:properties id="applicationProps" location="/WEB-INF/spring/application.properties"/> With the application version now accessible via SpEL, we can incorporate this into the use of the resources tag: - -<mvc:resources mapping="/resources-#{applicationProps['application.version']}/**" location="/public-resources/"/> + <mvc:resources mapping="/resources-#{applicationProps['application.version']}/**" location="/public-resources/"/> and finally, to request the resource with the proper URL, we can take advantage of the Spring JSP tags: - -<spring:eval expression="@applicationProps['application.version']" var="applicationVersion"/> + <spring:eval expression="@applicationProps['application.version']" var="applicationVersion"/> <spring:url value="/resources-{applicationVersion}" var="resourceUrl"> <spring:param name="applicationVersion" value="${applicationVersion}"/> @@ -4192,8 +4182,7 @@ application.version=1.0.0 To enable the feature using the default setup, simply include the tag in the form: - -<mvc:default-servlet-handler/> + <mvc:default-servlet-handler/> The caveat to overriding the "/" Servlet mapping is that the RequestDispatcher for the default Servlet must be retrieved @@ -4207,8 +4196,7 @@ application.version=1.0.0 the default Servlet name is unknown, then the default Servlet's name must be explicitly provided as in the following example: - -<mvc:default-servlet-handler default-servlet-name="myCustomDefaultServlet"/> + <mvc:default-servlet-handler default-servlet-name="myCustomDefaultServlet"/>