springMVC笔记关于多视图解析
来源:互联网 发布:万网科技域名找回密码 编辑:程序博客网 时间:2024/04/28 04:59
spring-mvc.xml 多视图解析代码 以下是4.x的版本
<?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"><context:component-scan base-package="com.wj.**.controller" /><aop:aspectj-autoproxy proxy-target-class="true" /><mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/> <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="mediaTypes"> <map><span style="white-space:pre"></span> <entry key="do" value="text/html" /><span style="white-space:pre"></span> <entry key="json" value="application/json" /> </map> </property> <property name="defaultContentType" value="text/html"/> </bean> <!-- 视图解析器 --><bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"><property name="order" value="0"/> <property name="contentNegotiationManager" ref="contentNegotiationManager"/> <property name="viewResolvers"><list><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/page/" /><property name="suffix" value=".jsp" /></bean></list></property><property name="defaultViews"><list><bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /></list></property></bean><mvc:default-servlet-handler /></beans>
<?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:component-scan base-package="com.wj.sms.interior.interfaces.**.controller" /> <mvc:annotation-driven /> <!-- 视图解析器 --><bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"><property name="mediaTypes"><map><entry key="html" value="text/html" /><entry key="json" value="application/json" /><entry key="img" value="image/jpeg"/></map></property><property name="viewResolvers"><list><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/views/" /><property name="suffix" value=".jsp" /></bean></list></property><property name="defaultViews"><list><bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /></list></property></bean></beans>
web.xml 配置
<servlet-mapping><servlet-name>springMVC</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>*.json</url-pattern>
</servlet-mapping>
0 0
- springMVC笔记关于多视图解析
- SpringMVC 多视图解析
- springMVC多视图解析器
- SpringMVC学习笔记 视图解析器
- SpringMVC支持解析多视图配置
- springmvc 多个视图解析器 排序
- springMVC 配置多个视图解析器
- SpringMVC中支持多视图解析
- springmvc配置多视图解析器
- springMvc 对多个视图后缀解析
- SpringMVC视图解析器
- SpringMVC视图解析器
- SpringMVC视图解析器
- SpringMVC视图解析器
- SpringMVC视图解析器
- SpringMVC视图解析器
- SpringMVC视图解析器
- SpringMVC视图解析器
- String为什么设置为不可变的
- Ubuntu ufw 使用
- Android Context完全解析,你所不知道的Context的各种细节
- Linux下gcc的使用以及库文件的链接
- fcntl函数用法详解
- springMVC笔记关于多视图解析
- pthread_join函数
- 算法导论第三版第8章思考题
- 初学者必看的html基础知识总结
- codeforces 600A Extract Numbers 模拟
- 235. Lowest Common Ancestor of a Binary Search Tree
- javascript中valueOf()和toString()区别
- android界面开发
- UDP