1. 程式人生 > >json轉換器對映檔案配置

json轉換器對映檔案配置

//MappingJacksonHttpMessageConverter轉換器,將物件轉為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>