<?xml version="1.0" encoding="UTF-8"?>
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:task="http://www.springframework.org/schema/task"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:util="http://www.springframework.org/schema/util"
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
http://www.springframework.org/schema/mvc
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context-4.0.xsd
|
http://www.springframework.org/schema/task
|
http://www.springframework.org/schema/task/spring-task-4.0.xsd
|
http://www.springframework.org/schema/util
|
http://www.springframework.org/schema/util/spring-util-2.0.xsd">
|
|
<context:component-scan base-package="com.nanometer.smartlab.api"/>
|
<context:component-scan base-package="com.nanometer.smartlab.controller"/>
|
|
<context:property-placeholder ignore-unresolvable="true" location="WEB-INF/config.properties" file-encoding="UTF-8"/>
|
<!-- 开启注解 -->
|
<!-- 默认的注解映射的支持,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -->
|
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager">
|
<mvc:message-converters register-defaults="true">
|
<!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
|
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
|
<constructor-arg value="UTF-8" />
|
</bean>
|
<!-- 将Jackson2HttpMessageConverter的默认格式化输出为false -->
|
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
<property name="supportedMediaTypes">
|
<list><value>application/json;charset=UTF-8</value></list>
|
</property>
|
<property name="prettyPrint" value="false"/>
|
</bean>
|
</mvc:message-converters>
|
</mvc:annotation-driven>
|
|
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
<property name="mediaTypes" >
|
<map>
|
<entry key="xml" value="application/xml"/>
|
<entry key="json" value="application/json"/>
|
</map>
|
</property>
|
<property name="ignoreAcceptHeader" value="true"/>
|
<property name="favorPathExtension" value="true"/>
|
</bean>
|
|
<mvc:cors>
|
<mvc:mapping path="/**" allowed-origins="*" allow-credentials="true" max-age="1800" allowed-methods="GET,POST"/>
|
</mvc:cors>
|
|
|
<mvc:resources mapping="/upload/**" location="file:${personImgPath}" />
|
<!-- 静态资源(js、image等)的访问 -->
|
<mvc:default-servlet-handler/>
|
</beans>
|