Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
713017ae
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
713017ae
编写于
9月 29, 2011
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polishing and formatting
上级
26087444
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
39 deletion
+27
-39
spring-framework-reference/src/mvc.xml
spring-framework-reference/src/mvc.xml
+27
-39
未找到文件。
spring-framework-reference/src/mvc.xml
浏览文件 @
713017ae
...
...
@@ -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>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录