$.ajax({
url:'http://xxx.test',
type: 'Post',
data: JSON.stringify(model),
dataType: 'json',
contentType : "application/json",
success: function (data) {
console.log(data);
//根据回调信息提示
if (data[0].result == 'success') {
layer.msg('获取成功');
} else {
layer.msg(data[0].message);
}
}
});              

今天一个同事遇到了一个500错误,程序如上所示,最开始以为数据太多,数据调少后,替换掉%等特殊字符不报,,解决办法有两种
1、如果使用JSON.stringify,一定要加contentType : "application/json"

2、或者不用JSON.stringfy,去掉contentType:"application/json"

在网上看到的一个讲解

http://stackoverflow.com/questions/11269622/asp-net-jquery-ajax-json-simple-example-of-exchanging-data
http://www.cnblogs.com/yanhua365/p/3458814.html
http://blog.csdn.net/mhmyqn/article/details/25561535 

content-type: application/json没有设置导致的500错误的更多相关文章

  1. Content type 'application/json;charset=UTF-8' not supported异常的解决过程

    首先说一下当时的场景,其实就是一个很简单的添加操作,后台传递的值是json格式的,如下图 ,后台对应的实体类, @Data @EqualsAndHashCode(callSuper = false) ...

  2. org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported

    最后找到我的问题,springmvc配置文件中没加 <mvc:annotation-driven/> java代码: @RequestMapping(value="/reques ...

  3. org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported或其他Content type不支持处理

    很久没从头到尾搭框架,今天搭的过程中,springmvc controller方法入参用@RequestBody自动绑定参数时一直提示各种 not supported 排查问题有两个解决路径: 1)使 ...

  4. SpringMVC在使用JSON时报错信息为:Content type 'application/json;charset=UTF-8' not supported

    直接原因是:我的(maven)项目parent父工程pom.xml缺少必要的三个jar包依赖坐标. 解决方法是:在web子模块的pom.xml里面添加springMVC使用JSON实现AJAX请求. ...

  5. ajax使用向Spring MVC发送JSON数据出现 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported错误

    ajax使用向Spring MVC发送JSON数据时,后端Controller在接受JSON数据时报org.springframework.web.HttpMediaTypeNotSupportedE ...

  6. Jmeter发送post请求报错Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    常识普及: Content-type,在Request Headers里面,告诉服务器,我们发送的请求信息格式,在JMeter中,信息头存储在信息头管理器中,所以在做接口测试的时候,我们维护Conte ...

  7. Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported告诉你,你的请求头是application/x- ...

  8. jmeter报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"的解决方法

    1.报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supporte ...

  9. 接入WxPusher微信推送服务出现错误:Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    背景 使用WxPusher微信推送服务 ,可以及时的将服务的一些运行异常信息,发送到自己的微信上,方便了解服务的运行状态(PS:这个服务是免费的). 你可以在这里看到WxPusher微信推送服务的接入 ...

随机推荐

  1. [CF1107E]Vasya and Binary String【区间DP】

    题目描述 Vasya has a string s of length n consisting only of digits 0 and 1. Also he has an array a of l ...

  2. 学习1__STM32--FatFS之逻辑盘符与物理盘符

    FatFS源代码中的函数逻辑关系 第一 调用函数 f_mount() result = f_mount(&fs, FS_VOLUME_NAND, ); /* Mount a logical d ...

  3. 对于rqy今天讲座的一些理解和看法吧

    其实我本来以为今天晚上要学高数的,但是听到任大佬要来讲课,我自然是很开心. 其实真正接触到他和照片给我的感觉完全不一样,rqy是一个非常单一的,没有在意其他过多的事情的人,包括从他的讲座来看,大佬把自 ...

  4. 牛客练习赛28 B数据结构(线段树)

    链接:https://www.nowcoder.com/acm/contest/200/B来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...

  5. DHU--1247 Hat’s Words && HiHocder--1014 Trie树 (字典树模版题)

    题目链接 DHU--1247 Hat’s Words HiHocder--1014 Trie树 两个一个递归方式一个非递归 HiHocoder #include<bits/stdc++.h> ...

  6. springcloud干货之服务注册与发现(Eureka)

    springcloud系列文章的第一篇 springcloud服务注册与发现 使用Eureka实现服务治理 作用:实现服务治理(服务注册与发现) 简介: Spring Cloud Eureka是Spr ...

  7. Linux安装Gitlab,附iSCSI分区挂载说明

    因为Gitlab数据要存放在共享存储,所以本次配置的重头戏倒变成了挂载ISCSI了. OS:CentOS 7.2IP:172.16.1.191/192.168.2.191 iSCSI分Target(服 ...

  8. 解题:NOI2018 你的名字(68pts暴力)

    题面 rt,如果省选没退役就补 SAM的优势:简单明了 先建S的SAM并标记所有节点,之后每次询问直接把T按广义SAM的方法插上去,统计新加的节点到根的状态代表的本质不同子串数,减掉被标记的部分就是T ...

  9. python面向对象编程 -- 基本概念

    面向对象的编程简要概括就是将要处理的问题抽象为数据和操作的集合,用类对其进行封装.其中数据和操作都称为类的属性,它们是一般是不变的. 对类进行实例化生成我们所说的对象,对象有自己的属性.对象的属性一般 ...

  10. Good Bye 2018 A. New Year and the Christmas Ornament

    传送门 https://www.cnblogs.com/violet-acmer/p/10201535.html 题解: 这题没什么好说的,读懂题意就会了. 比赛代码: #include<ios ...