Код: Выделить всё
{errCode: 4000, errMsg: "Failed to parse multipart servlet request", timestamp: "01-04-2025 07:26:30"}
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
< /code>
angular 17 < /p>
importProducts(productId,file:File, tag): Observable {
var url = "http://localhost:9100/importProduct/“+productId+"?tag="+tag;
var headers: HttpHeaders = new HttpHeaders();
headers = headers.set('content-type', 'multipart/form-data');
this.http.combineHeaders(headers);
return this.http.post(url, file, 'ImportProducts');
}
< /code>
java17 < /p>
@PostMapping(value = "/importProduct/{product_id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity importProductList(@PathVariable(value = "product_id") String productId,
@RequestParam(value = "tag") boolean tag, @RequestParam("uploadFile") MultipartFile uploadFile)
throws IOException {
if ((uploadFile.getName() == null) || "".equals(uploadFile.getName())) {
//Error file
} else if (uploadFile.getSize() == 0) {
//Error stream null
} else {
String newFile = uploadFile.getOriginalFilename();
if (tag) {
//Import products process
return new ResponseEntity(true, HttpStatus.OK);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... because-no