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>  




  • 相关阅读:
    SharePoint 2007中的Permission Level与Permission之间的关系
    如何确定一个SharePoint列表的ID?
    经典线程死锁
    SharePoint的Workflow History列表在哪里?
    SharePoint Designer中设计的workflow出错了, 怎么办?
    清除MOSS的Timer Job Cache的方法 Clear the SharePoint Configuration Cache
    sp_MSforeachtable和sp_MSforeachdb
    sa安全
    几个排名函数的区别
    递归限制
  • 原文地址:https://www.cnblogs.com/vvch/p/4871746.html
Copyright © 2011-2022 走看看