123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?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:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:cache="http://www.springframework.org/schema/cache"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:task="http://www.springframework.org/schema/task"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">
- <!-- 扫描包,默认扫描所有 com.tqe下的所有注解 -->
- <context:component-scan base-package="com.tqe"/>
- <aop:aspectj-autoproxy />
- <!-- mvc注解驱动 -->
- <mvc:annotation-driven conversion-service="conversionService" >
- <mvc:argument-resolvers>
- <bean class="com.tqe.base.web.resolver.PageVOHandlerMethodArgumentResolver" />
- </mvc:argument-resolvers>
- </mvc:annotation-driven>
- <!-- 启用缓存注解功能,这个是必须的,否则注解不会生效,另外,该注解一定要声明在spring主配置文件中才会生效 -->
- <cache:annotation-driven cache-manager="cacheManager" />
- <bean
- class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
- <!-- spring mvc请求映射 -->
- <bean
- class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
- <property name="synchronizeOnSession" value="true"/>
- </bean>
- <bean id="conversionService"
- class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
- <property name="converters">
- <set>
- <bean class="com.tqe.base.converter.StringConverter"/>
- </set>
- </property>
- </bean>
- <!-- 视图解释类 -->
- <bean
- class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <!-- //Controler 返回的ModeAndView自动到此目录下找对应jsp为后缀的文件 -->
- <property name="prefix" value="/WEB-INF/jsp/" />
- <property name="suffix" value=".jsp" /><!--可为空,方便实现自已的依据扩展名来选择视图解释类的逻辑 -->
- <!-- 使用Jsp作为视图解释层 -->
- <property name="viewClass"
- value="org.springframework.web.servlet.view.JstlView" />
- </bean>
- <!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理 -->
- <mvc:resources mapping="/image/**" location="/image/" />
- <mvc:resources mapping="/css/**" location="/css/" />
- <mvc:resources mapping="/js/**" location="/js/" />
- <mvc:resources mapping="/fonts/**" location="/fonts/" />
- <!-- 文件上传 -->
- <bean id="multipartResolver"
- class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
- <property name="defaultEncoding" value="utf-8"/>
- <property name="maxInMemorySize" value="40960"/>
- <!-- 最大上传20M文件 -->
- <property name="maxUploadSize" value="20971520"/>
- </bean>
- <!-- 导入mybatis的配置信息 -->
- <import resource="spring-mybatis.xml" />
- <!-- 配置拦截器 -->
- <mvc:interceptors>
- <mvc:interceptor>
- <mvc:mapping path="/admin/stuEval*" />
- <bean class="com.tqe.interceptor.StuEvalInterceptor"/>
- </mvc:interceptor>
- <mvc:interceptor>
- <mvc:mapping path="/admin/teaEval*" />
- <bean class="com.tqe.interceptor.TeaEvalInterceptor"/>
- </mvc:interceptor>
- </mvc:interceptors>
- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
- <property name="messageConverters">
- <list>
- <bean class = "org.springframework.http.converter.StringHttpMessageConverter">
- <property name = "supportedMediaTypes">
- <list>
- <value>text/plain;charset=UTF-8</value>
- </list>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- <!-- 配置responseBody 结果返回json数据 -->
- <bean id="jsonConverter"
- class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" >
- </bean>
-
- <!-- spring自己的换管理器,这里定义了两个缓存位置名称 ,既注解中的value -->
- <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
- <property name="caches">
- <set>
- <bean
- class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
- p:name="mCache" />
- </set>
- </property>
- </bean>
- <!-- 全局异常处理 -->
- <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
- <!-- 定义默认的异常处理页面,当该异常类型的注册时使用 -->
- <property name="defaultErrorView" value="error"/>
- <!-- 定义异常处理页面用来获取异常信息的变量名,默认名为exception -->
- <property name="exceptionAttribute" value="ex"/>
- <!-- 定义需要特殊处理的异常,用类名或完全路径名作为key,异常也页名作为值 -->
- <property name="exceptionMappings">
- <props>
- <prop key="com.tqe.base.exception.UserNotExistException">error</prop>
- <!-- 这里还可以继续扩展对不同异常类型的处理 -->
- </props>
- </property>
- </bean>
- <!-- Spring Task 定时任务 -->
- <task:annotation-driven scheduler="springScheduler" mode="proxy"/>
- <task:scheduler id="springScheduler" pool-size="10"/>
- </beans>
|