1.对象参数类型JSON化: data:JSON.parse(JSON.stringify(object)),
2.头部信息headers: "Content-Type": "application/json; charset=UTF-8"
3.service中请求方式写为POST
4.后台controller中获得参数方式:@RequestBody String Object
5.String转换为json:JSONObject accident=JSONObject.fromObject(newsObject);
public int save(@RequestBody String newsObject) {
JSONObject accident=JSONObject.fromObject(newsObject);
JSONObject accident2=JSONObject.fromObject(accident.get("newsObject"));//需要import net.sf.json.JSONObject========需要添加依赖json-lib
......
}
(注:JSONObject将外部为{}的String类型转换为JSONObject;JSONArray是将外部为[]的String类型转换为JSONArray)