先看问题
代码
ajax
$.ajax({
type: "POST",
url: "/sswz/user/goregister",
dataType: "html",
async: false,
data: {
identity: identity,
account: account,
password: password,
Confirmpassword: Confirmpassword,
realname: realname,
telephone: telephone
},
success: function (result) {
if (result === "accountnull") {
layer.open({
type: 1
, offset: 'auto'
, content: '<div style="padding: 20px 100px;">' + '账户不能为空' + '</div>'
, btn: '确定'
, btnAlign: 'c' //按钮居中
, skin: 'demo-class'
, shade: 0 //不显示遮罩
, icon: 7
, yes: function () {
layer.closeAll();
}
});
} else if (result === "passwordnull") {
layer.alert('密码不能为空',{icon:7});
} else if (result === "namenull") {
layer.alert('真实姓名不能为空',{icon:7});
} else if (result === "telnull") {
layer.alert('电话不能为空',{icon:7});
} else if (result === "notequal") {
layer.alert('两次密码不一致',{icon:2});
} else if (result === "success") {
layer.open({
type: 1
, offset: 'auto'
, content: '<div style="padding: 20px 100px;">' + '注册成功!' + '</div>'
, btn: '确定'
, btnAlign: 'c' //按钮居中
, skin: 'demo-class'
, shade: 0 //不显示遮罩
, icon: 7
, yes: function () {
window.location.href = "/sswz/index.html";
layer.closeAll();
}
});
}
}
});
java
@GetMapping("/user/register")
public String toregister()
{
return "register";
}
@PostMapping("/user/goregister")
@ResponseBody
public String register(String identity, String account, String password, String Confirmpassword,
String realname, String telephone) {
if (account == null || "".equals(account)) {
return "accountnull";
} else if ("".equals(password) || "".equals(Confirmpassword)) {
return "passwordnull";
} else if ("".equals(realname)) {
return "namenull";
} else if ("".equals(telephone)) {
return "telnull";
} else if (!password.equals(Confirmpassword) ) {
return "notequal";
} else {
System.out.println(1);
return "success";
}
}