spring-mvc.xml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
  4. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  5. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  6. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
  7. <context:property-placeholder
  8. ignore-resource-not-found="true" location="classpath*:spring/application.properties" />
  9. <!-- 自动扫描且只扫描@Controller -->
  10. <context:component-scan base-package="com.xt.jygl" use-default-filters="false">
  11. <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
  12. </context:component-scan>
  13. <bean id="SpringApplicationContext" class="com.xtframe.core.utils.ApplicationContextHelper"></bean>
  14. <mvc:annotation-driven >
  15. <mvc:message-converters>
  16. <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
  17. <bean id="mappingJacksonHttpMessageConverter"
  18. class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
  19. <property name="supportedMediaTypes">
  20. <list>
  21. <value>text/html;charset=UTF-8</value>
  22. </list>
  23. </property>
  24. </bean>
  25. </mvc:message-converters>
  26. </mvc:annotation-driven>
  27. <mvc:view-controller path="/" view-name="redirect:/main" />
  28. <mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
  29. <mvc:resources mapping="/static/**" location="/static/" />
  30. <mvc:default-servlet-handler />
  31. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  32. <property name="prefix" value="/WEB-INF/pages/" />
  33. <property name="suffix" value=".jsp" />
  34. </bean>
  35. <bean class="com.xt.jygl.common.ExceptionResolver">
  36. <property name="bizLogRecorder" ref="bizLogRecorder" />
  37. <property name="exceptionMappings">
  38. <props>
  39. <prop key="org.apache.shiro.authz.UnauthorizedException">error/403</prop>
  40. <prop key="java.lang.Exception">error/500</prop>
  41. </props>
  42. </property>
  43. </bean>
  44. <!-- WebService -->
  45. <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
  46. <property name="baseAddress"
  47. value="http://${webService.url}:${webService.port}/" />
  48. </bean>
  49. <!-- AOP式方法级权限检查 -->
  50. <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
  51. <property name="proxyTargetClass" value="true" />
  52. </bean>
  53. <mvc:interceptors>
  54. <mvc:interceptor>
  55. <mvc:mapping path="/**" />
  56. <bean class="com.xtframe.web.support.LoggerInterceptor">
  57. <property name="bizLogRecorder" ref="bizLogRecorder" />
  58. </bean>
  59. </mvc:interceptor>
  60. </mvc:interceptors>
  61. <!-- file upload -->
  62. <bean id="multipartResolver"
  63. class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  64. <!-- set the max upload size100MB -->
  65. <property name="maxUploadSize" value="20971520"></property>
  66. <property name="maxInMemorySize" value="4096"></property>
  67. <property name="defaultEncoding" value="UTF-8"></property>
  68. </bean>
  69. </beans>