1、文件上传时,报“415 unsupported type”。

解决:使用​@ModelAttribute​​ 而不是​@RequestBody。​

​测试:​

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">

<head>
<title>Hello World!</title>
<meta charset="utf-8">
</head>

<body>
<form method="POST" enctype="multipart/form-data" action="http://127.0.0.1:8888/upload">
<p>文件1:<input type="text" name="id" /></p>
<p>文件2:<input type="text" name="name" /></p>
<p>文件3:<input type="file" name="file" /></p>
<p><input type="submit" value="上传" /></p>
</form>
</body>

</html>
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public String upload(@ModelAttribute FileUpload fileUpload) {
return "ok";
}

2、Failed to deserialize payload. Is the byte array a result of反序列化错误。

解决:清空redis缓存。

1、redis安装目录下输入cmd                            

2、redis-cli -p 端口号

3、flushdb 清除当前数据库缓存

4、flushall 清除整个redis所有缓存

3、下载文件报错org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

解决:函数返回改为void,或者使用函数@Controller。

4、位置属性 FlowableException: Unknown property used in expression

解决:记得加getter方法呀。

SpringBoot 报错锦集_后端