java.io.IOException: Server returned HTTP response code: 415 for URL:xxxxxx

java.io.IOException: Server returned HTTP response code: 415 for URL: http://192.168.1.59:8080/mobileapi/scene/save.do?token=9DB2FD6FDD2F116CD47CE6C48B3047EE

at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)

java.io.IOException: Server returned HTTP response code: 415 for URL:xxxxxx_第1张图片

环境描述

Spring MVC 使用 @RequestBody 接收JSON参数转为实体对象

public void save(@RequestBody Scene scene, HttpServletRequest

request, HttpServletResponse response) throws Exception {


}

客户端添加下面的代码解决问题:

connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");

 引用地址:https://blog.csdn.net/testcs_dn/article/details/71716647

你可能感兴趣的:(笔记)