$(function(){
$('#confirm').click(function(){
var password=$('#password').val();
var re_password=$('#re_password').val();
if(password.length<=0){
alert("密码不能为空");
}else if(password!=re_password){
alert("两次密码不一致")
}
var datas ={"password":password};
console.log("datas"+datas.password);
$.ajax({
url:'/settingpassword.xhtml',
type:'post',
contentType: "application/json;charset=utf-8",
data:datas,
error:function(data){
alert(data.password);
}
})
})
})
ajax date 为空
```
@RequestMapping("/settingpassword.xhtml")
public void settingpassword(@RequestParam("password") String password,HttpServletRequest request){
Integer er=null;
JSONArray jsonArray=JSONArray.fromObject(password);
System.out.println( " 参数 ---- "+ jsonArray);
Iterator<Object> it = jsonArray.iterator();
while(it.hasNext()){
JSONObject obj = (JSONObject)it.next();
System.out.println("password:"+obj.get("password"));
er=(Integer) obj.get("agentHouseID");
}
System.out.println("你好");
}
后端