日期:2014-05-16 浏览次数:20724 次
$.ajax({ type:'post', url:'${pageContext.request.contextPath}/jsp/squsergl/checkUserAccount.action',//调用的action data:{'userAccount':userAccount,'date':d},//请求的参数 success:function(msg){ if(msg==1) { $("#span1").html("<font color='red'>此用户帐号已被占用</font>"); } if(msg==0) { $("#span1").html("<font color='blue'>此用户帐号可以使用</font>"); } } });
<action name="checkUserAccount" class="squserglAction" method="checkUserAccount"></action>
public void checkUserAccount() throws IOException { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse res=ServletActionContext.getResponse(); String userAccount=request.getParameter("userAccount"); System.out.println(userAccount); List list=squserglService.findCheckUserAccount(userAccount);//查询一下数据库,有没有该用户 if(list.size()>0) { res.getWriter().print(1); } else { res.getWriter().print(0); } }