zoukankan      html  css  js  c++  java
  • spring mvc json

    问题背景:
        使用了springmvc+velocity的项目,返回json出现了问题

    问题描述:
        出现了406错误
        
    找不到要解析成的头部!

    问题原因:
        缺少json转换配置

    解决办法:
        在对应的servlet配置文件中添加
       
    xmlns:mvc="http://www.springframework.org/schema/mvc" 

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

    <mvc:annotation-driven>
             <mvc:message-converters register-defaults="false">
                <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                    <property name="supportedMediaTypes">
                        <list>
                            <value>text/html;charset=UTF-8</value>
                            <value>application/json;charset=UTF-8</value>
                            <value>application/*+json;charset=UTF-8</value>
                        </list>
                    </property>
                </bean>
            </mvc:message-converters>
         </mvc:annotation-driven>  




  • 相关阅读:
    三极管8050和8550对管的参数
    三极管9014 管脚
    水深不语,人稳不言
    编译结果分析
    三母运算符
    C语言关键词解释
    51定时器初值的计算
    聪明人都在远离手机虚假繁荣的“人脉”关系
    每段路,都是一种领悟
    你的灯亮着吗读后感二
  • 原文地址:https://www.cnblogs.com/vvch/p/4871746.html
Copyright © 2011-2022 走看看