前台 :
var jsonMarker =JSON.stringify(newMarkers)
$.ajax({
type: "post",
url:"saveMapMaker",
data:jsonMarker,
contentType: "application/json; charset=utf-8",
dataType: "json",
success:function(date){
alert(date.msg);
}
});
后台
@ResponseBody
@RequestMapping(value = "saveMapMaker", method = RequestMethod.POST )
public AjaxDto saveMarker( @RequestBody String marker ) throws JsonParseException, JsonMappingException, IOException{
ObjectMapper objectMapper = new ObjectMapper();
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, TMapMaker.class);
List<TMapMaker> list = objectMapper.readValue(marker, javaType);
mapService.saveAll(list);
AjaxDto a =new AjaxDto();
a.setMsg("success");
return a;
}