You're trying to decode an invalid JSON String JSON返回有解析问题
SpringMVC架构的web程序,通常用map返回消息在浏览器中显示,但是实际中报下列错误
“”You're trying to decode an invalid JSON String“
返回的字符串的被加入了<pre></pre>, 解决方法,在springMvc的配置文件中加入以下配置: <bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean
class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean id="jsonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>application/json</value>
</list>
</property>
</bean>
</list>
</property>
</bean> 同时,在Controller方法体上加入@ResponseBody注解。 另外还有一种解决方法是返回数组形式的消息,如:
resultText ="{success:true,info:'成功'}";
You're trying to decode an invalid JSON String JSON返回有解析问题的更多相关文章
- Array(数组)与Json String (Json字符串) 的相互转换
1.Array转换成Json String function jsonToString(arr) { var s = ""; ...
- SQL中采用Newtonsoft.Json处理json字符串
原文 SQL中采用Newtonsoft.Json处理json字符串 使用环境: SQL Server2005; VS2010; 关于SQL中部署CLR程序集的方法,网上一搜一大把,需要了解的自行查阅, ...
- Golang的Json encode/decode以及[]byte和string的转换
使用了太长时间的python,对于强类型的Golang适应起来稍微有点费力,不过操作一次之后发现,只有这么严格的类型规定,才能让数据尽量减少在传输和解析过程中的错误.我尝试使用Golang创建了一个公 ...
- convert NameValueCollection/Dictionary<string, object> to JSON string
public static class WebExtension { public static T Decode<T>(this RequestBase res) { Type type ...
- JSON.parse(),JSON.stringify(),jQuery.parseJSON()的用法
1. JSON.parse(jsonString): 在一个字符串中解析出JSON对象 var str = '[{"href":"baidu.com",&quo ...
- 转:关于JSON.parse(),JSON.stringify(),jQuery.parseJSON()的用法
1. JSON.parse(jsonString): 在一个字符串中解析出JSON对象 ? 1 2 3 var str = '[{"href":"baidu.com&qu ...
- 4. JSON字符串是如何被解析的?JsonParser了解一下
公司不是你家,领导不是你妈.本文已被 https://www.yourbatman.cn 收录,里面一并有Spring技术栈.MyBatis.JVM.中间件等小而美的专栏供以免费学习.关注公众号[BA ...
- .Net使用Newtonsoft.Json.dll(JSON.NET)对象序列化成json、反序列化json示例教程
JSON作为一种轻量级的数据交换格式,简单灵活,被很多系统用来数据交互,作为一名.NET开发人员,JSON.NET无疑是最好的序列化框架,支持XML和JSON序列化,高性能,免费开源,支持LINQ查询 ...
- 使用Newtonsoft.Json.dll(JSON.NET)动态解析JSON、.net 的json的序列化与反序列化(一)
在开发中,我非常喜欢动态语言和匿名对象带来的方便,JSON.NET具有动态序列化和反序列化任意JSON内容的能力,不必将它映射到具体的强类型对象,它可以处理不确定的类型(集合.字典.动态对象和匿名对象 ...
随机推荐
- C/C++ XMPP/Jabber 客户端类库对比/点评 (转)
原文转自 http://blog.csdn.net/educast/article/details/31359835 1.gloox Ans. 老牌库,推荐 gloox是一个稳定功能完整的XMPP客户 ...
- hdu 4504(动态规划)
威威猫系列故事——篮球梦 Time Limit: 300/100 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...
- LeetCode OJ——Remove Duplicates from Sorted List
http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/ 链表的去重,要考虑链表的本质. #include <ios ...
- Integration_Unit test coding standard
Integration & Unit test coding standard 命名规则 好的命名规则,直接从命名就可以清楚的知道该测试方法测试的内容和目的,而不用额外的添加注释说明.对于MV ...
- E. Sergey and Subway
比赛时候写复杂了…… 我写的是 计算每个节点树内所有点到某个点的距离和. #include <bits/stdc++.h> using namespace std; typedef lon ...
- 缓存区溢出检测工具BED
缓存区溢出检测工具BED 缓存区溢出(Buffer Overflow)是一类常见的漏洞,广泛存在于各种操作系统和软件中.利用缓存区溢出漏洞进行攻击,会导致程序运行失败.系统崩溃.渗透测试人员利用这 ...
- QBXT T15565 Day4上午道路分组
有向并查集维护连通性 优化: vis数组表示能被节点1到达的点 显然,已经分在一个联通块中的点就没必要在用该点扩展了. #include<cstdio> #include<algor ...
- 【APIO2016】Gap
题目描述 有 $N$ 个严格递增的非负整数 $a_1, a_2, \dots, a_N$($0 \leq a_1 < a_2 < \cdots < a_N \leq 10^{18}$ ...
- Mac os x 10.8 svn server的搭建
Mac自带了svn服务端和客户端,所以我们不用再去下载了. 1 但首先 sudo vi /etc/paths 将xcode里的Contents/developer/usr/bin加入到path ...
- 一道简单DP题
问题: 给定一个整数的数组,相邻的数不能同时选,求从该数组选取若干整数,使得他们的和最大,要求只能使用o(1)的空间复杂度.要求给出伪码. 解答: int maxSum(vector<int&g ...