[org.springframework.web.HttpMediaTypeNotSupportedException:....
前端:data要注意值是json字符串,然后注意一下contentType的属性,如果你改送的是json
// 发送ajax请求
$.ajax({
type: "post",
url: "/demo/handle10",
data: JSON.stringify({"id":"1923","name":"zhuangjie"}),
dataType: "json",
contentType:'application/json;charset=utf-8',
success: function(result){
console.log("ok",result);
}
})
后端:不然也会报415
要加入依赖
<!--json数据交互所需jar,start--> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.9.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.9.0</version>