-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
spring boot version:1.4.2.RELEASE
controller:
@RestController
@RequestMapping("/issues")
public class IssuesController {
@RequestMapping(value="/miss",method=RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)
public void miss(@RequestBody MultiValueMap<String, String> values){
System.out.println(values);
}
}
Request:
method:PUT
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Reponse:
{
"timestamp": 1482387184078,
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "Required request body is missing: public void io.github.ztgoto.issues.controller.IssuesController.miss(org.springframework.util.MultiValueMap<java.lang.String, java.lang.String>)",
"path": "/issues/miss"
}
issues in org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.EmptyBodyCheckingHttpInputMessage.EmptyBodyCheckingHttpInputMessage(HttpInputMessage inputMessage)
PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
int b = pushbackInputStream.read();
b=-1 body=null
The cause of the problem
org.springframework.web.filter.HttpPutFormContentFilter#doFilterInternal
org.springframework.web.filter.HiddenHttpMethodFilter#doFilterInternal
Refer to the servlet specification:
3.1.1 When Parameters Are Available
The following are the conditions that must be met before post form data will be
populated to the parameter set:
1. The request is an HTTP or HTTPS request.
2. The HTTP method is POST.
3. The content type is application/x-www-form-urlencoded.
4. The servlet has made an initial call of any of the getParameter family of methods
on the request object.
If the conditions are not met and the post form data is not included in the parameter
set, the post data must still be available to the servlet via the request object’s input
stream. If the conditions are met, post form data will no longer be available for
reading directly from the request object’s input stream.
sample
sample
Metadata
Metadata
Assignees
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid