[英]PUT method generating error when sending data with multipart form data
I am sending some data with multipart data in put methos in spring mvc. 我在Spring MVC中使用放置方法发送多部分数据。 The sme process is working with post request but generating an error in put request. sme进程正在处理后期请求,但在放置请求中生成错误。 this is my code snippet: 这是我的代码段:
@RequestMapping(value= "update/{id}", method = RequestMethod.PUT, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Product update(@PathVariable("id") int id,@RequestParam("name") String name,@RequestParam("price") int price @RequestPart("file") MultipartFile file) {
}
The error generated is: HTTP Status 400 - Required String parameter 'name' is not present 生成的错误是:HTTP状态400-必需的字符串参数'name'不存在
type Status report 类型状态报告
message Required String parameter 'name' is not present 消息必需的字符串参数“名称”不存在
description The request sent by the client was syntactically incorrect. 描述客户端发送的请求在语法上不正确。
thnx for all to answer the question. 感谢所有人回答这个问题。 I got my answer and that is we can not use multipart/form data with put because put takes a single entry 我得到了答案,那就是我们不能与put一起使用多部分/表单数据,因为put只需输入一个条目
Please see How are PUT parameters passed to a page? 请参阅如何将PUT参数传递到页面? . 。 The parameters must be in the body, not in the URL or the header. 参数必须在正文中,而不是URL或标题中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.