60 lines
2.8 KiB
XML
60 lines
2.8 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:context="http://www.springframework.org/schema/context"
|
||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
|
||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||
|
||
<!-- 启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射 -->
|
||
<!-- <mvc:annotation-driven/> -->
|
||
<mvc:default-servlet-handler />
|
||
|
||
<!-- 自动扫描且只扫描@Controller -->
|
||
<context:component-scan base-package="com"
|
||
use-default-filters="false">
|
||
<!-- 平台的controller,可以写多个 -->
|
||
<context:include-filter type="aspectj" expression="com.bonus..*Controller" />
|
||
</context:component-scan>
|
||
|
||
<!-- 启动组件扫描,排除@Controller组件,该组件由SpringMVC配置文件扫描 -->
|
||
<context:component-scan base-package="com.bonus">
|
||
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
|
||
</context:component-scan>
|
||
|
||
<!-- 对静态资源文件的访问 restful -->
|
||
<mvc:resources mapping="/static/**" location="/,/static/" />
|
||
|
||
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||
<property name="viewClass"
|
||
value="org.springframework.web.servlet.view.JstlView"></property>
|
||
<property name="prefix" value="/WEB-INF/views/"></property>
|
||
<property name="suffix" value=".jsp"></property>
|
||
</bean>
|
||
|
||
<mvc:annotation-driven>
|
||
<mvc:message-converters register-defaults="true">
|
||
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
|
||
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
||
<property name="supportedMediaTypes">
|
||
<list>
|
||
<value>text/html;charset=UTF-8</value>
|
||
<value>text/json;charset=UTF-8</value>
|
||
<value>application/json;charset=UTF-8</value>
|
||
</list>
|
||
</property>
|
||
</bean>
|
||
</mvc:message-converters>
|
||
</mvc:annotation-driven>
|
||
<!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->
|
||
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||
<!-- 默认编码 -->
|
||
<property name="defaultEncoding" value="utf-8" />
|
||
<!-- 文件大小最大值 -->
|
||
<property name="maxUploadSize" value="1048576000" />
|
||
<!-- 内存中的最大值 -->
|
||
<property name="maxInMemorySize" value="40960" />
|
||
</bean>
|
||
<import resource="spring-datasource-test.xml"/>
|
||
</beans>
|