1. 程式人生 > >spring.xml配置

spring.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/c"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<context:component-span base-package="com.echo.digital"/>

<import resource="spring-mybatis.xml"/>

<mvc:default-servlet-handler/>

<mvc:annotation-driven/>

<!--json轉換器-->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<!-- <constructor-arg ref="utf8Charset"/> -->
<!-- <property name="supportedMediaTypes" value = "text/plain;charset=UTF-8" /> -->
<property name="writeAcceptCharset" value="false" /><!-- 用於避免響應頭過大 -->
<property name = "supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
<!-- <value>text/json;charset=UTF-8</value> -->
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name = "supportedMediaTypes">
<list>
<value>text/json;charset=UTF-8</value>
</list>
</property>

</bean>
</mvc:message-converters>
</mvc:annotation-driven>
</beans>