spring配置json

来源:互联网 发布:python 读写文本文件 编辑:程序博客网 时间:2024/06/05 04:40
<bean id="jsonConverter"        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">        <property name="supportedMediaTypes">            <list>                <value>text/plain;charset=UTF-8</value>                <value>text/html;charset=UTF-8</value>                <value>application/json;charset=UTF-8</value>            </list>        </property>    </bean>    <bean        class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">        <property name="messageConverters">            <list>                <ref bean="jsonConverter" />            </list>        </property>    </bean>

将这个配置文件加入到spring配置文件中,即可,将数据转换为json

0 0
原创粉丝点击