日期:2014-05-20 浏览次数:20803 次
function ajaxcheck() { alert("ajax"); var obj = document.form1; var name=obj.username.value.trim();//trim()功能删除字符串首部和尾部的空格 var pwd=obj.password.value.trim(); alert(name); ajaxcommon.doCheck(name,pwd,reloadym); } function reloadym(msg) { if(msg){ alert("欢迎登录"); }else{ alert("用户名或密码错误"); } //document.location.reload(true); window.location.href="welcome.jsp"; }
public boolean doCheck(String name,String password){ WebContext webContext = WebContextFactory.get(); HttpServletRequest request = webContext.getHttpServletRequest(); HttpServletResponse response = webContext.getHttpServletResponse(); System.out.println("00:"+request.getContextPath()); TabUser operator = new TabUser(); operator.setUsername(name); operator.setPassword(password); List<TabUser> userlist = userService.findUser(operator); System.out.println("11"); if(userlist.size()==0){ request.setAttribute("msg","1"); System.out.println("msg:"+request.getAttribute("msg")); System.out.println("22"); return false; }else{ System.out.println("33"); request.setAttribute("msg","2"); System.out.println("msg:"+request.getAttribute("msg")); return true; // String html = webContext.forwardToString("/welcome.jsp"); // return html; } }