使用的是SpringBoot框架,部分代码如下
JS代码:
function login() {
var userName = $("#inputName").val();
var userPassword = $("#inputPassword").val();
var rememberUser = $("input[type=checkbox]").get(0).checked;
$.ajax({
url : "login/userLogin",
type : "post",
dataType : "json",
data : {
"userName" : userName,
"userPassword" : userPassword
},
success : function(result) {
if (result.status == 1) {
if (rememberUser) {
addCookie("userName", userName, 30);
} else {
delCookie("userName");
}
window.location.href = "menu.html";
} else if (result.status == 0) {
alert(result.message);
}
}
});
return false;
}
Controller代码:
@RequestMapping(value = "login/userLogin", method = RequestMethod.POST)
@ResponseBody
public Result login(User user) {
Result result = userService.login(user);
return result;
}
登录form提交后,每次都是显示返回的json,而不是跳转到menu.html,应该怎么改
LEATH
相关分类