java - PUT 和 POST - 参数相同,但 PUT 请求错误

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

我有 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 结果:

发布方法 enter image description here

放置方法 enter image description here

请帮忙。提前致谢

最佳答案

几个月前,我在开发 RESTful 服务时遇到了同样的问题。

添加 HttpPutFormContentFilter帮助我解决了这个问题。

引用: SpringMVC Not Recognizing Body Parameters While Using PUT

关于java - PUT 和 POST - 参数相同,但 PUT 请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52543173/

相关文章:

java - 在txt文件中查找特定文本并将其存储在String中

spring - 如何在 spring Restapi 的 json 请求中的未知字段上抛出错误

spring - DDD - 在 Spring Data 中维护单独的域类和实体类

node.js - 将 request.post 的内容类型 header 设置为 json

java - 列表迭代器导致堆分配?

java - Android Activity LifeCycle,应用程序运行时运行 while 循环的方法是什么?

spring-boot - 我想获取MongoTemplate的findAndModify返回值作为修改后的值

java - Java 中的 HTTP "POST"

java - HttpURLConnection 即使在 setDoOutput(true)、setRequestMethod ("POST") setRequestProperty("Content

java - 如何在不需要 @SuppressWarnings 的情况下正确编码此泛型