0
私はLongとDoubleをSpringコントローラ用のAjaxに送信したいと思います。Ajaxを使用してLongとDoubleをSpringコントローラに送信する方法は?
var id = $(this).data('customer-id');
var quantity = $('#quantity-' + id).val();
$.ajax({
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
type: "POST",
url: '/changeQuantityOrder',
data: {idOrder: id, quantityChange: quantity},
error: function(e) {
console.log(e);
},
success: function (msg) {
window.location.href = "/administrationNotSleeps";
}
私は、コードを受信しよう:私は見て、この例外(MissingServletRequestParameterException)https://stackoverflow.com/
について発見した。しかし、この
@RequestMapping(value = "/changeQuantityOrder", method = {RequestMethod.POST})
public @ResponseBody Long editCustomerOrder(@RequestParam(value = "idOrder")Long id,
@RequestParam(value = "quantityChange")Double quantity){
System.out.println("Id:"+id+" Quantity "+quantity);
return id;
}
しかし、私は例外
{"timestamp":1490775639761,"status":400,"error":"Bad Request","exception":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required Long parameter 'idOrder' is not present","path":"/changeQuantityOrder"}"
を受け取ります記事は3年前に書かれた、多分何か変わった?
今はString to Springコントローラを送信してから、それ以降はjavaでsplit
を使用します。