Why doesn't this work? I am trying this against my Spring 3.2 MVC application. It works with POST requests.
curl -X PUT http://localhost:8080/bananas/1 --form data='{"description":"Hei", "status":"REJECTED"};type=application/json'
java.lang.IllegalArgumentException: Failed to obtain request part: data. The part is missing or multipart processing is not configured.
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity updateQuestion(@PathVariable final int id,
@RequestPart(value = "data") final Banana banana,
@RequestPart(value = "image", required = false) final MultipartFile imageFile) {
In reality PUT requests are supposed to work on Request Body (or payload) and not on Request Parameters. In that sense, servlet API & spring's handling is correct.
A better easier way to pass no data element from your jquery and javascript call.Pass your parameter as part of url.Means Set parameter in the url field.otherwise u have to do your code using GET.
var x=10;
$.ajax({
url: "/ritesh/" + x + "/patil" + "?param1=param2Val&..",
type: "PUT",
data: "",
success: function(response) {
// ....
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.