spring mvc+jackson的错误

Catelyn 发布于 2013/12/17 19:43
阅读 5K+
收藏 0

exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('i' (code 105)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

无论我提交的是双引号,如下,还是单引号都报上面的异常

var params = {"id":"123","name":"zj"};

然后我改了配置

<bean id="mappingJacksonHttpMessageConverter"
                  class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>application/json;charset=UTF-8</value>
                    </list>
                </property>
                <property name="objectMapper" ref="customObjectMapper"/>
</bean>
<bean id="customObjectMapper" class="cn.com.blossomframework.services.view.web.util.CustomObjectMapper" />



public class CustomObjectMapper extends ObjectMapper{
    public CustomObjectMapper(){
       super();
       this.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES,true);
    }
}

就算我换成默认的

<mvc:annotation-driven />



并且提交的数据也是双引号,问题依旧!


what the fuck? 大神求救!!!!!!!!!!!!!!
加载中
0
peanutmain
peanutmain
我觉得不是后台引起错误的,是你js提交的格式有问题, Unexpected character ('i' (code 
peanutmain
peanutmain
回复 @惉惉自喜 : 回答错了,如上
peanutmain
peanutmain
能否看一下你的前台js提交的数据代码
Catelyn
Catelyn
诡异的是我提交的是双引号
0
开源中国时时彩理财师
开源中国时时彩理财师
{"id":"123","name":"zj"} 改成  {id: "123", name: "zj"}试试
0
z
zzc315

使用转义字符\":{"id":"123","name":"zj"}  改成 {\"id\":\"123\",\"name\":\"zj\"}

返回顶部
顶部