Spring MVC ContentNegotiatingViewResolver 样例
2015-09-16 10:00
405 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhaojian0910/article/details/48489819
spring-controller.xml 中配置 ContentNegotiatingViewResolver
<!-- 根据客户端不同的请求进行不同的相应,如/blog/1.do ,/blog/1.xml --> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <!-- 设置为true以忽略对Accept Header的支持 --> <property name="ignoreAcceptHeader" value="true" /> <!-- 在没有扩展名时即: "/blog/1" 时的默认展现形式 --> <property name="defaultContentType" value="application/json" /> <!-- 扩展名至mimeType的映射,即 /blog.json => application/json --> <property name="mediaTypes"> <map> <entry key="html" value="text/html" /> <entry key="xml" value="application/xml" /> <entry key="json" value="application/json" /> </map> </property> <!-- 用于开启 /blog/123?format=json 的支持 --> <property name="favorParameter" value="false" /> <property name="favorPathExtension" value="true"></property> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="suffix" value=".jsp" /> <property name="prefix" value="/" /> </bean> </list> </property> <property name="defaultViews"> <list> <!-- for application/json --> <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /> <!-- for application/xml --> <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> <property name="marshaller"> <bean class="org.springframework.oxm.xstream.XStreamMarshaller"/> </property> </bean> </list> </property> </bean>
相关文章推荐
- Spring MVC ContentNegotiatingViewResolver 样例 根据不同的url地址后缀返回不同类型的数据...
- spring mvc ContentNegotiatingViewResolver 根据路径后缀,选择不同视图
- Spring 4 MVC ContentNegotiatingViewResolver Example
- SpringMVC ContentNegotiatingViewResolver -- 根据请求资源名选择视图
- spring-mvc 3.2.0 多视图解析配置实例 ContentNegotiatingViewResolver
- Spring 3 MVC ContentNegotiatingViewResolver Example
- spring-mvc 3.2.0 多视图解析配置实例 ContentNegotiatingViewResolver
- SpringMVC ContentNegotiatingViewResolver -- 根据请求资源名选择视图
- Spring 3 MVC ContentNegotiatingViewResolver example
- springmvc<一>一种资源返回多种形式【ContentNegotiatingViewResolver】
- 实现Spring 4 MVC ContentNegotiatingViewResolver example
- 转载Spring 3 MVC ContentNegotiatingViewResolver
- Spring mvc ContentNegotiatingViewResolver 根据路径后缀,选择不同视图
- spring-mvc多视图解析配置实例 ContentNegotiatingViewResolver
- Spring 3 MVC ContentNegotiatingViewResolver example
- org.springframework.web.servlet.view.ContentNegotiatingViewResolver 配置
- ContentNegotiatingViewResolver spring REST中的内容协商(同一资源,多种展现:xml,json,html)
- spring-freemarker.xml 视图解析器 ContentNegotiatingViewResolver 源码分析
- Spring ContentNegotiatingViewResolver
- ContentNegotiatingViewResolver spring REST中的内容协商(同一资源,多种展现:xml,json,html)