简体   繁体   English

当发送包含多部分表单数据的数据时,PUT方法生成错误

[英]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.

相关问题 在Android中发送多部分表单数据 - Sending Multipart Form Data in Android 使用 multipart/form-data 发送 POST 方法时出现@ModelAttribute 问题 - Problem with @ModelAttribute while sending POST method with multipart/form-data 为什么在Java中以multipart / form-data发送文件时为什么必须同时使用Writer和OutputStream? - Why does when sending a file in multipart/form-data in java we have to use both a Writer and a OutputStream? IE 11:发送Multipart Form Data请求时出错:Stream意外结束 - IE 11: Error while sending Multipart Form Data request: Stream ended unexpectedly 405 错误:带有 Spring 的多部分/表单数据 - 405 Error : multipart/form-data with Spring 解析多部分表单数据时的异常 - exception when parsing multipart form data 如何使用 Spring MockMvc 放置多部分/表单数据? - How to PUT multipart/form-data using Spring MockMvc? 使用Jersey发送多个文件:找不到multipart / form-data的MessageBodyWriter - Sending multiple files with Jersey: MessageBodyWriter not found for multipart/form-data 通过 Postman 发送多部分/表单数据请求的困难 - Difficulties sending multipart/form-data request via Postman 将类对象发送到期望包含多部分数据的Web服务 - Sending a class object to a multipart-form-data-expected web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM