问题

使用Postman测试上传接口,如下:

1572685108871

1572685150224

请求,报错:

org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
    at org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:831) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:256) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:280) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    at org.apache.catalina.connector.Request.parseParts(Request.java:2868) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
    ...

解决

出现这个的原因是因为Postman会自动加上Content-Type:multipart/form-data这对请求头信息,不需要我们手动添加,将其删除即可:

1572685416677


Viva La Vida