1.今天在调试客户端向服务器端发送json数据时,出现415
2.解决方案:
2.1是否在ajax中书写了 contentType:"application/json;
我发现我书写了,但是还是不行,我又查看了请求头,发现和content-Type是对应的,没问题的
2.2最后找到问题,查看导入的依赖包是否正确
我导入的是alibaba.fastjson,我更改了依赖包就好了
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.3</version>
</dependency>