The request params are shown in the network but the second param (fileId) is received as null in the controller. The request returns 400 bad request.
@PostMapping(path = "/uploadFile")
public ResponseEntity<ServiceResponse> upload(
@RequestParam(value = "id") Long userId,
@RequestParam(value = "fileId") Long fileId,
@RequestPart(value = "file") MultipartFile... file) {
//
return ResponseEntity.ok(serviceResponse);
}
request URL: (the file is sent in the body: formData) http://localhost:8080/api/upload?id=9999&fileId=101
好吧,您能否至少显示您的请求或 URL?
你的 URL 应该是http://localhost:8080/api/uploadFile?id=9999&fileId=101
而不是http://localhost:8080/api/upload?id=9999&fileId=101
因为你已经提到了作为 uploadFile 的路径
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.