spring-mvc.xml 3.3 KB
<?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"
	   xmlns:aop="http://www.springframework.org/schema/aop"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

	<!-- 扫面那个包 -->
	<context:component-scan base-package="com.sibu.orderHelper.integralMall.controller.*" />

	<!-- 启用扫描 -->
	<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
	<mvc:annotation-driven>
		<mvc:message-converters register-defaults="true">
			<bean class="com.sibu.orderHelper.common.converter.UTF8StringHttpMessageConverter" />
			<!-- 配置Fastjson 替换原来的jackson支持 -->
			<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
				<property name="supportedMediaTypes">
					<list>
						<value>text/html;charset=UTF-8</value>
						<value>application/json</value>
					</list>
				</property>
				<property name="features">
					<list>

						<value>QuoteFieldNames</value> <!-- 输出key时是否使用双引号,默认为true -->
						<value>WriteMapNullValue</value>  <!-- 是否输出值为null的字段,默认为false -->
						<value>DisableCircularReferenceDetect</value>
						<!--

                        <value>WriteDateUseDateFormat</value>
                        <value>WriteNullStringAsEmpty</value>  字符类型字段如果为null,输出为"",而非null
                        <value>WriteNullNumberAsZero</value>  数值字段如果为null,输出为0,而非null
                        <value>WriteNullBooleanAsFalse</value>  Boolean字段如果为null,输出为false,而非null
                        <value>WriteNullListAsEmpty</value>    List字段如果为null,输出为[],而非null
                        -->

					</list>
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>

	<mvc:default-servlet-handler/>

	<!-- 将静态文件指定到某个特殊的文件夹中统一处理 -->
	<mvc:resources location="/resources/" mapping="/resources/**" />

	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/page/" />
		<property name="suffix" value=".jsp" />
	</bean>

	<!-- 全局异常处理 -->
	<bean id="exceptionResolver"
		class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
		<property name="exceptionMappings">
			<props>
				<prop key="com.sibu.orderHelper.Exception.NullException">error</prop>
			</props>
		</property>
	</bean>

	<!-- 设置multipartResolver才能完成文件上传,文件上传 -->
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize" value="5000000"></property>
	</bean>

</beans>