ssh框架中ajax对用户名查重的代码

1 form表单

 


2 ajax代码


3 后端代码

// 1判断用户是否已经注册
public String Preregist() throws Exception{
//获取参数username
String username=ServletActionContext.getRequest().getParameter("username");
System.out.println(username);
Business b=adminService.findByUsername(username);
//判断user 写回信息
if(b == null){
ServletActionContext.getResponse().getWriter().println("1");
}else{
ServletActionContext.getResponse().getWriter().println("0");
}
return NONE;
}
//2注册
public String regist(){
//为用户生成uuid
business.setBid(UUIDUtils.getId());
adminService.regist(business);
return "home";
}

你可能感兴趣的:(ssh)