日期:2014-05-16 浏览次数:20394 次
function login(){,
$.ajax({
'url':'${ctx}/user.do?method=login',
'data':{'email':$('#email').val(),'password':$('#password').val()},
'type':'post',
'dataType':'Json',
'success':function(data,statusText){
alert(data);//success
alert(data=='success');//false
if(data=='success'){
alert('进来了~!');
closeBg();
}
if(data=='fail'){
$('#msg').html('账号或者密码错误');
}
}
});
}
@RequestMapping(params="method=login")
public void login(HttpServletRequest request,HttpServletResponse response) throws Exception{
System.out.println("here");
String email=request.getParameter("email");
String password=request.getParameter("password");
User user=userService.findByEmail(email, password);
System.out.println("user:"+user);
PrintWriter out=response.getWriter();
if(user!=null){
request.getSession().setAttribute("user", user);
out.println("success");
out.close();
}
else{
out.println("fail");
out.close();
}
}
out.println 这个方法会多个换行符
用
out.print