ajax请求后台controller的时候发送过去的内容编码类型:
用类型一:contentType: “application/json; charset=utf-8”, 发送数据内容格式给服务器
后台用@RequestBody接收,例子如下:
后台controller:
@RequestMapping(value = "/doRegister",method=RequestMethod.POST)
@ResponseBody
/* public String doRegister(@RequestParam("username") String username ,@RequestParam(value = "password",required = false) String password
,@RequestParam(value = "phone",required = false) String phone ,@RequestParam(value = "idNum",required = false) String idNum
,@RequestParam(value = "realName",required = false) String realName){
logger.info("doRegister() 方法被调用");
boolean result=userService.registerData(username,phone,password,idNum,realName);*/
public String doRegister(@RequestBody UserVO uservo){ //实体接收方式
System.out.println("doRegister= realName===="+uservo.getRealName());
//注册方法....
if(result==true){
return "login";
}
return "register";
}