Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
f2c9838e
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,发现更多精彩内容 >>
提交
f2c9838e
编写于
9月 09, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated ContentNegotiatingViewResolver example towards ContentNegotiationManager
Issue: SPR-13431
上级
99f72ce3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
17 deletion
+8
-17
src/asciidoc/web-mvc.adoc
src/asciidoc/web-mvc.adoc
+8
-17
未找到文件。
src/asciidoc/web-mvc.adoc
浏览文件 @
f2c9838e
...
...
@@ -2861,24 +2861,15 @@ representation of the current resource regardless of the logical view name. The
header may include wild cards, for example `text/{asterisk}`, 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 `mediaTypes` to specify a mapping of file
extensions to media types. For more information on the algorithm used to determine the
request media type, refer to the API documentation for `ContentNegotiatingViewResolver`.
To support custom resolution of a view based on a file extension, use a
`ContentNegotiationManager`: see
<
<
mvc-config-content-negotiation
>
>.
Here is an example configuration of a `ContentNegotiatingViewResolver
:`
Here is an example configuration of a `ContentNegotiatingViewResolver
`:
[source,xml,indent=0]
[subs="verbatim,quotes"]
----
<bean
class=
"org.springframework.web.servlet.view.ContentNegotiatingViewResolver"
>
<property
name=
"mediaTypes"
>
<map>
<entry
key=
"atom"
value=
"application/atom+xml"
/>
<entry
key=
"html"
value=
"text/html"
/>
<entry
key=
"json"
value=
"application/json"
/>
</map>
</property>
<property
name=
"viewResolvers"
>
<list>
<bean
class=
"org.springframework.web.servlet.view.BeanNameViewResolver"
/>
...
...
@@ -2890,7 +2881,7 @@ Here is an example configuration of a `ContentNegotiatingViewResolver:`
</property>
<property
name=
"defaultViews"
>
<list>
<bean
class=
"org.springframework.web.servlet.view.json.MappingJackson2JsonView"
/>
<bean
class=
"org.springframework.web.servlet.view.json.MappingJackson2JsonView"
/>
</list>
</property>
</bean>
...
...
@@ -4867,9 +4858,9 @@ that in turn can be created with a `ContentNegotiationManagerFactoryBean`:
<mvc:annotation-driven
content-negotiation-manager=
"contentNegotiationManager"
/>
<bean
id=
"contentNegotiationManager"
class=
"org.springframework.web.accept.ContentNegotiationManagerFactoryBean"
>
<property
name=
"favorPathExtension"
value=
"false"
/>
<property
name=
"favorParameter"
value=
"true"
/>
<property
name=
"mediaTypes"
>
<property
name=
"favorPathExtension"
value=
"false"
/>
<property
name=
"favorParameter"
value=
"true"
/>
<property
name=
"mediaTypes"
>
<value>
json=application/json
xml=application/xml
...
...
@@ -4884,7 +4875,7 @@ for request mapping purposes, and `RequestMappingHandlerAdapter` and
`ExceptionHandlerExceptionResolver` for content negotiation purposes.
Note that `ContentNegotiatingViewResolver` now can also be configured with a
`ContentNegotiati
ngViewResolver`, so you can use one
instance throughout Spring MVC.
`ContentNegotiati
onManager`, so you can use one shared
instance throughout Spring MVC.
In more advanced cases, it may be useful to configure multiple
`ContentNegotiationManager` instances that in turn may contain custom
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录