springMvc 主配置文件 笔记 总结备用
2017-03-08 17:13
417 查看
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd"> <!-- Spring MVC配置 --> <context:annotation-config /> <!--扫描注解 --> <context:component-scan base-package="com.mu.*" /> <!--默认的mvc注解映射的支持 --> <!-- 处理 springMvc 处理结果乱码问题,如返回 fastjson 字符串--> <mvc:annotation-driven > <mvc:message-converters register-defaults="true"> <!-- 配置Fastjson支持 --> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> <value>text/plain;charset=UTF-8</value> </list> </property> <property name="features"> <list> <value>QuoteFieldNames</value> <value>WriteMapNullValue</value> <value>WriteNullListAsEmpty</value> <value>WriteNullStringAsEmpty</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 支持异步方法执行 --> <task:annotation-driven /> <!--Spring自动扫描被@Aspect标注的切面了 用于aopaspectj方式自动扫描 --> <aop:aspectj-autoproxy proxy-target-class="true" /> <!-- 视图解析器和json解析器 --> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <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.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/" /> <!--可为空,方便实现自已的依据扩展名来选择视图解释类的逻辑 --> <property name="suffix" value=".jsp"/> </bean> </list> </property> <!-- <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /> </list 4000 > </property> --> </bean> <!-- 总错误处理 --> <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="defaultErrorView"> <value>error/error</value> </property> <property name="defaultStatusCode"> <value>500</value> </property> <property name="warnLogCategory"> <value>org.springframework.web.servlet.handler.SimpleMappingExceptionResolver </value> </property> </bean> <!-- 对静态资源文件的访问 --> <mvc:resources mapping="/images/**" location="/images/" cache-period="31556926" /> <mvc:resources mapping="/js/**" location="/js/" cache-period="31556926" /> <mvc:resources mapping="/css/**" location="/css/" cache-period="31556926" /> <!-- 加载属性文件 --> <!-- <context:property-placeholder location="classpath:jdbc.properties" /> --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/config/jdbc.properties</value> </list> </property> <property name="fileEncoding"> <value>UTF-8</value> </property> </bean> </beans>
相关文章推荐
- springmvc笔记之 -- 配置文件简单例子
- PHP 错误与异常 笔记与总结(5)配置文件中与错误日志相关的选项 && 将错误记录到指定的文件中
- springMVC-笔记003-spring配置文件
- springmvc配置文件web.xml详解各方总结。
- springmvc笔记之 -- 配置文件
- Linux备用常用笔记——etc目录下主要配置文件解释
- Linux总结笔记6-配置Samba服务实现Linux和Windows之间文件共享
- SpringMVC学习笔记1_XML配置文件
- SpringMvc文件配置总结
- Linux 计划任务 Crontab 笔记与总结(3)Crontab 配置文件
- springmvc:配置文件总结
- springMVC学习笔记---修改配置文件路径和传递数据
- Linux总结笔记7-配置NFS服务实现Linux间文件共享
- springMVC-笔记001-mvc配置文件
- PHP 错误与异常 笔记与总结(3)PHP 配置文件(php.ini)中与错误相关的选项 与 设置错误级别
- springmvc配置文件web.xml详解各方总结。
- springmvc笔记(基本配置,核心文件,路径,参数,文件上传,json整合)
- springmvc配置文件web.xml详解各方总结(转载)
- springmvc配置文件web.xml详解各方总结。
- springMVC-笔记002-web配置文件