我有 requestMapping("projects") 的 Post 方法和 Put 方法。
@PutMapping
public ResponseEntity<ResultDomain> updateProjet(@RequestParam String projectJSON,
@RequestParam MultipartFile image, @RequestParam(required = false) MultipartFile image1,
@RequestParam(required = false) MultipartFile image2) throws Exception {
}
@PostMapping
public ResponseEntity<ResultDomain> addProjet(@RequestParam String projectJSON, @RequestParam MultipartFile image,
@RequestParam(required = false) MultipartFile image1, @RequestParam(required = false) MultipartFile image2)
throws Exception {
}
这两个方法具有完全相同的参数。当我请求 POST 时,我没有任何问题。但是当我请求 PUT 时,它将返回错误的请求。 PUT方法有什么限制吗?
postman 结果:
请帮忙。提前致谢
最佳答案
几个月前,我在开发 RESTful 服务时遇到了同样的问题。
添加 HttpPutFormContentFilter帮助我解决了这个问题。
引用: SpringMVC Not Recognizing Body Parameters While Using PUT
关于java - PUT 和 POST - 参数相同,但 PUT 请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52543173/