applicationContext-test.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
  6. xmlns:cache="http://www.springframework.org/schema/cache"
  7. xmlns:p="http://www.springframework.org/schema/p"
  8. xmlns:task="http://www.springframework.org/schema/task"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans
  10. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  11. http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
  12. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  13. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  14. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
  15. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
  16. http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">
  17. <!-- 扫描包,默认扫描所有 com.tqe下的所有注解 -->
  18. <context:component-scan base-package="com.tqe"/>
  19. <aop:aspectj-autoproxy />
  20. <bean
  21. class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
  22. <!-- spring mvc请求映射 -->
  23. <bean
  24. class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
  25. <property name="synchronizeOnSession" value="true"/>
  26. </bean>
  27. <!-- 导入mybatis的配置信息 -->
  28. <import resource="spring-mybatis.xml" />
  29. <!-- 配置拦截器 -->
  30. <mvc:interceptors>
  31. <mvc:interceptor>
  32. <mvc:mapping path="/admin/stuEval*" />
  33. <bean class="com.tqe.interceptor.StuEvalInterceptor"/>
  34. </mvc:interceptor>
  35. <mvc:interceptor>
  36. <mvc:mapping path="/admin/teaEval*" />
  37. <bean class="com.tqe.interceptor.TeaEvalInterceptor"/>
  38. </mvc:interceptor>
  39. </mvc:interceptors>
  40. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
  41. <property name="messageConverters">
  42. <list>
  43. <bean class = "org.springframework.http.converter.StringHttpMessageConverter">
  44. <property name = "supportedMediaTypes">
  45. <list>
  46. <value>text/plain;charset=UTF-8</value>
  47. </list>
  48. </property>
  49. </bean>
  50. </list>
  51. </property>
  52. </bean>
  53. <!-- 配置responseBody 结果返回json数据 -->
  54. <bean id="jsonConverter"
  55. class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" >
  56. </bean>
  57. <!-- 全局异常处理 -->
  58. <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
  59. <!-- 定义默认的异常处理页面,当该异常类型的注册时使用 -->
  60. <property name="defaultErrorView" value="error"/>
  61. <!-- 定义异常处理页面用来获取异常信息的变量名,默认名为exception -->
  62. <property name="exceptionAttribute" value="ex"/>
  63. <!-- 定义需要特殊处理的异常,用类名或完全路径名作为key,异常也页名作为值 -->
  64. <property name="exceptionMappings">
  65. <props>
  66. <!--<prop key="cn.basttg.core.exception.ParameterException">error-parameter</prop>-->
  67. <!-- 这里还可以继续扩展对不同异常类型的处理 -->
  68. </props>
  69. </property>
  70. </bean>
  71. </beans>