PUT和POST-相同的参数,但对PUT的请求不正确

时间:2018-09-27 18:33:54

标签: java spring-boot http-post spring-restcontroller http-put

我有Post方法和Put方法用于requestMapping(“ projects”)。

@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 {
}

这2种方法具有完全相同的参数。当我请求POST时,我没有问题。但是,当我请求PUT时,它将返回错误的请求。 PUT方法有什么限制吗?

邮递员结果:

POST方法 enter image description here

放置方法 enter image description here

请帮助。预先感谢

2 个答案:

答案 0 :(得分:2)

几个月前,我在使用RESTful服务时遇到了相同的问题。

添加property可以帮助我解决此问题。

参考: HttpPutFormContentFilter

答案 1 :(得分:0)

最后,我可以通过将@RequestParam String projectJSON替换为@RequestPart String projectJSON来解决它。还是不知道为什么。有人可以解释吗?感谢您的好意。。

相关问题