繁体   English   中英

在控制器中读取 requestparam 时出现问题

[英]Problem reading requestparam in controller

请求参数显示在网络中,但第二个参数 (fileId) 在控制器中被接收为 null。 该请求返回 400 个错误的请求。

@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);
}

请求URL:(文件在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 的路径

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM