polishing and formatting
This commit is contained in:
parent
2608744479
commit
713017aedc
|
@ -1825,8 +1825,7 @@ public class EditPetForm {
|
|||
<classname>HttpPutFormContentFilter</classname>, which can be
|
||||
configured in <filename>web.xml</filename>:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<filter>
|
||||
<programlisting language="xml"><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>
|
||||
|
||||
<lineannotation><!— in <literal>views.xml</literal> --></lineannotation>
|
||||
<lineannotation><!-- in <literal>views.xml</literal> --></lineannotation>
|
||||
|
||||
<beans>
|
||||
<bean name="report" class="org.springframework.example.ReportExcelView"/>
|
||||
|
@ -2710,8 +2709,9 @@ public String upload(...) {
|
|||
<classname>Views</classname> that can render an appropriate
|
||||
representation of the current resource regardless of the logical view
|
||||
name. The <literal>Accept</literal> header may include wild cards, for
|
||||
example text/*, in which case a <classname>View</classname> whose
|
||||
Content-Type was text/xml is a compatible match.</para>
|
||||
example <literal>text/*</literal>, in which case a
|
||||
<classname>View</classname> whose Content-Type was
|
||||
<literal>text/xml</literal> is a compatible match.</para>
|
||||
|
||||
<para>To support the resolution of a view based on a file extension, use
|
||||
the <classname>ContentNegotiatingViewResolver </classname>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:
|
||||
<programlisting language="xml">
|
||||
POST /someUrl
|
||||
<programlisting>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 ...
|
||||
</programlisting></para>
|
||||
... File Data ...</programlisting></para>
|
||||
|
||||
<para>You could access the part named "meta-data" with a
|
||||
<interfacename>@RequestParam("meta-data") String
|
||||
|
@ -3615,14 +3613,12 @@ public class SimpleController {
|
|||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><classname>AdminController</classname> maps to the
|
||||
<literal>/admin</literal><emphasis role="bold">/*</emphasis> request
|
||||
URL</para>
|
||||
<literal>/admin/*</literal> request URL</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><classname>CatalogController</classname> maps to the
|
||||
<literal>/catalog</literal><emphasis role="bold">/*</emphasis>
|
||||
request URL</para>
|
||||
<literal>/catalog/*</literal> request URL</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
@ -3794,12 +3790,15 @@ public class SimpleController {
|
|||
}</programlisting>
|
||||
|
||||
<programlisting language="xml"><?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">
|
||||
|
||||
<lineannotation><!-- this bean with the well known name generates view names for us --></lineannotation>
|
||||
<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">
|
||||
<lineannotation><!-- inject dependencies as necessary --></lineannotation>
|
||||
|
@ -4044,16 +4043,14 @@ public class SimpleController {
|
|||
<para>An example of registering an interceptor applied to all URL
|
||||
paths:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:interceptors>
|
||||
<programlisting language="xml"><mvc:interceptors>
|
||||
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
|
||||
</mvc:interceptors></programlisting>
|
||||
|
||||
<para>An example of registering an interceptor limited to a specific URL
|
||||
path:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:interceptors>
|
||||
<programlisting language="xml"><mvc:interceptors>
|
||||
<mvc:interceptor>
|
||||
<mapping path="/secure/*"/>
|
||||
<bean class="org.example.SecurityInterceptor" />
|
||||
|
@ -4073,8 +4070,7 @@ public class SimpleController {
|
|||
<para>An example of view-controller that forwards to a home page is
|
||||
shown below:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:view-controller path="/" view-name="home"/></programlisting>
|
||||
<programlisting language="xml"><mvc:view-controller path="/" view-name="home"/></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="mvc-static-resources">
|
||||
|
@ -4098,15 +4094,13 @@ public class SimpleController {
|
|||
directory within the web application root, the tag would be used as
|
||||
follows:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:resources mapping="/resources/**" location="/public-resources/"/></programlisting>
|
||||
<programlisting language="xml"><mvc:resources mapping="/resources/**" location="/public-resources/"/></programlisting>
|
||||
|
||||
<para>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:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:resources mapping="/resources/**" location="/public-resources/" cache-period="31556926"/></programlisting>
|
||||
<programlisting language="xml"><mvc:resources mapping="/resources/**" location="/public-resources/" cache-period="31556926"/></programlisting>
|
||||
|
||||
<para>The <code>mapping</code> attribute must be an Ant pattern that can
|
||||
be used by <classname>SimpleUrlHandlerMapping</classname>, and the
|
||||
|
@ -4119,8 +4113,7 @@ public class SimpleController {
|
|||
<code>/META-INF/public-web-resources/</code> in any jar on the
|
||||
classpath, the tag would be specified as:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/public-web-resources/"/></programlisting>
|
||||
<programlisting language="xml"><mvc:resources mapping="/resources/**" location="/, classpath:/META-INF/public-web-resources/"/></programlisting>
|
||||
|
||||
<para>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</programlisting>
|
|||
<para>and then to make the properties file's values accessible to SpEL
|
||||
as a bean using the <code>util:properties</code> tag:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<util:properties id="applicationProps" location="/WEB-INF/spring/application.properties"/></programlisting>
|
||||
<programlisting language="xml"><util:properties id="applicationProps" location="/WEB-INF/spring/application.properties"/></programlisting>
|
||||
|
||||
<para>With the application version now accessible via SpEL, we can
|
||||
incorporate this into the use of the <code>resources</code> tag:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:resources mapping="/resources-#{applicationProps['application.version']}/**" location="/public-resources/"/></programlisting>
|
||||
<programlisting language="xml"><mvc:resources mapping="/resources-#{applicationProps['application.version']}/**" location="/public-resources/"/></programlisting>
|
||||
|
||||
<para>and finally, to request the resource with the proper URL, we can
|
||||
take advantage of the Spring JSP tags:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<spring:eval expression="@applicationProps['application.version']" var="applicationVersion"/>
|
||||
<programlisting language="xml"><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</programlisting>
|
|||
<para>To enable the feature using the default setup, simply include the
|
||||
tag in the form:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:default-servlet-handler/></programlisting>
|
||||
<programlisting language="xml"><mvc:default-servlet-handler/></programlisting>
|
||||
|
||||
<para>The caveat to overriding the "/" Servlet mapping is that the
|
||||
<code>RequestDispatcher</code> for the default Servlet must be retrieved
|
||||
|
@ -4207,8 +4196,7 @@ application.version=1.0.0</programlisting>
|
|||
the default Servlet name is unknown, then the default Servlet's name
|
||||
must be explicitly provided as in the following example:</para>
|
||||
|
||||
<programlisting language="xml">
|
||||
<mvc:default-servlet-handler default-servlet-name="myCustomDefaultServlet"/></programlisting>
|
||||
<programlisting language="xml"><mvc:default-servlet-handler default-servlet-name="myCustomDefaultServlet"/></programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
|
Loading…
Reference in New Issue