When I send a Json object from ajax jquery with the "contentType" property, the back-end that this case is java , not find the json element or the request is null
this is JS
var urlInsert = '/SAF/ajax/supplier/insert';
console.log(rfc);
$.ajax({
type : 'POST',
url : urlInsert,
data:{
proveedor : jsonObj //jsonObj is a JSON.stringify()
},
dataType : "json",
contentType : "appliaction/json",
mimeType : "applicaction/json",
success : onInsert,
error : function(data, status, er) {
alert("Load Data: " + data + ", Estatus: " + status + ", Error: "
+ er);
}
});
it's method in my controller JAVA
@RequestMapping(value="insert",method=RequestMethod.POST)
public void onInsert(HttpServletRequest request, HttpServletResponse response){
Gson gson = new Gson();
SafTcProveedor proveedor = gson.fromJson(request.getParameter("proveedor"), SafTcProveedor.class);
System.out.println(proveedor);
}
mimeType, and make sure yourdatais wrapped withJSON.stringifysince the server expects a JSON string