Ajax访问SpringMVC的Controller进入error
##* JSP
记得我
##*Ajax
function login(that) {
$.ajax({
data: "username=" + $("#username").val() + "&password=" + $("#password").val(),
type: "post",
url: "/checklogin",
dataType: "json",
error: function (data) {
alert("出现异常,请稍后重试");
$(that).removeClass("processing");
},
success: function (response) {
$(that).removeClass("processing");
if (response == "error") {
$("#msg").text("用户名或密码错误");
} else {
window.location.href = "/welcome";
}
}
});
}
##Controller
@Controller
public class LoginController {
@Autowired
private UserService userService;
@RequestMapping("/checklogin")
@ResponseBody
public String checkLogin(@RequestParam("username") String username, @RequestParam("password") String password, HttpSession session){
User user = userService.login(username, password);
if(user != null){
return "success";
}
else{
return "error";
}
}
}
error返回(object object)
刚刚学习虚心请教