91 lines
4.3 KiB
XML
91 lines
4.3 KiB
XML
|
|
<?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:p="http://www.springframework.org/schema/p"
|
|||
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|||
|
|
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
|
|||
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|||
|
|
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
|||
|
|
http://www.springframework.org/schema/context
|
|||
|
|
http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
|||
|
|
http://www.springframework.org/schema/aop
|
|||
|
|
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
|
|||
|
|
http://www.springframework.org/schema/mvc
|
|||
|
|
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
|
|||
|
|
<!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 -->
|
|||
|
|
<context:component-scan base-package="com.sipai.controller" />
|
|||
|
|
<mvc:annotation-driven>
|
|||
|
|
<mvc:message-converters>
|
|||
|
|
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
|
|||
|
|
<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>
|
|||
|
|
</list>
|
|||
|
|
</property>
|
|||
|
|
</bean>
|
|||
|
|
</mvc:message-converters>
|
|||
|
|
</mvc:annotation-driven>
|
|||
|
|
<mvc:resources mapping="/**" location="/" />
|
|||
|
|
<!-- 不拦截静态资源/放行資源文件 -->
|
|||
|
|
<mvc:default-servlet-handler/>
|
|||
|
|
<!--避免IE执行AJAX时,返回JSON出现下载文件 -->
|
|||
|
|
<bean id="mappingJacksonHttpMessageConverter"
|
|||
|
|
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
|||
|
|
<property name="supportedMediaTypes">
|
|||
|
|
<list>
|
|||
|
|
<value>text/html;charset=UTF-8</value>
|
|||
|
|
</list>
|
|||
|
|
</property>
|
|||
|
|
</bean>
|
|||
|
|
<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
|
|||
|
|
<bean
|
|||
|
|
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
|
|||
|
|
<property name="messageConverters">
|
|||
|
|
<list>
|
|||
|
|
<ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 -->
|
|||
|
|
</list>
|
|||
|
|
</property>
|
|||
|
|
</bean>
|
|||
|
|
<bean class="com.sipai.tools.SwaggerConfig"/>
|
|||
|
|
<mvc:resources location="classpath:/META-INF/resources/" mapping="doc.html"/>
|
|||
|
|
<mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>
|
|||
|
|
|
|||
|
|
<!-- 定义跳转的文件的前后缀 ,视图模式配置-->
|
|||
|
|
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
|||
|
|
<!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->
|
|||
|
|
<property name="prefix" value="/jsp/" />
|
|||
|
|
<property name="suffix" value=".jsp" />
|
|||
|
|
</bean>
|
|||
|
|
<!-- 用于一般类调用SERVICE -->
|
|||
|
|
<bean id="SpringContextUtil" class="com.sipai.tools.SpringContextUtil" scope="singleton"></bean>
|
|||
|
|
|
|||
|
|
<!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->
|
|||
|
|
<bean id="multipartResolver"
|
|||
|
|
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
|||
|
|
<!-- 默认编码 -->
|
|||
|
|
<property name="defaultEncoding" value="utf-8" />
|
|||
|
|
<!-- 文件大小最大值 -->
|
|||
|
|
<property name="maxUploadSize" value="10485760000" />
|
|||
|
|
<!-- 内存中的最大值 -->
|
|||
|
|
<property name="maxInMemorySize" value="40960" />
|
|||
|
|
</bean>
|
|||
|
|
|
|||
|
|
<!-- 启动AOP AspectJ注解自动代理 -->
|
|||
|
|
<aop:aspectj-autoproxy />
|
|||
|
|
<!-- 通知spring使用cglib而不是jdk的来生成代理方法 AOP可以拦截到Controller -->
|
|||
|
|
<aop:config proxy-target-class="true"></aop:config>
|
|||
|
|
<mvc:interceptors>
|
|||
|
|
<mvc:interceptor>
|
|||
|
|
<mvc:mapping path="/**"/>
|
|||
|
|
<bean class="com.sipai.tools.MVCIntercetpor"></bean>
|
|||
|
|
</mvc:interceptor>
|
|||
|
|
</mvc:interceptors>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<!-- 用于启动成功后执行后期补票线程池 -->
|
|||
|
|
<bean id="StartupListener" class="com.sipai.tools.StartupListener"></bean>
|
|||
|
|
|
|||
|
|
</beans>
|