POST JSON在415个不受支持的媒体类型Spring3MVC中失败
var productCategory = new Object();productCategory.idProductCategory = 1; productCategory.description = "Descrizione2";newCategory(productCategory);
function newCategory(productCategory){ $.postJSON("ajax/newproductcategory", productCategory, function( idProductCategory) { console.debug("Inserted: " + idProductCategory); });}
$.postJSON = function(url, data, callback) { return jQuery.ajax({ 'type': 'POST', 'url': url, 'contentType': 'application/json', 'data': JSON.stringify(data), 'dataType': 'json', 'success': callback });};
{"idProductCategory":1,"description":"Descrizione2"}
@RequestMapping(value = "/ajax/newproductcategory", method = RequestMethod.POST) public @ResponseBodyInteger newProductCategory(HttpServletRequest request, @RequestBody ProductCategory productCategory)
Helenr
小唯快跑啊