以String的形式进行json数据的传入
后台controller接收:
@ResponseBody
public String addRegister(@RequestBody String requestBody,HttpServletRequest request){
String paramStr = new String(requestBody.getBytes(), Charset.forName("utf-8"));
String result = modelService.addRegisterUser(paramStr);
return result;
}
业务处理(接收之后进行json转换为对象):
UserTest userTest = JSONObject.parseObject(jsonStr, UserTest.class);
如果要把对象返回成json数据(result为自写的返回对象)
return result.toJSONObject().toJSONString();