/** 校验(重写 ActionSupport 父类的方法进行校验) */ public void validateDoRegist() { // 1.email 非空 String email = model.getEmail(); if (!ValidateUtil.isValidate(email)) { addFieldError("email", "email 不能为空!"); } if (!ValidateUtil.isValidate(model.getUsername())) { addFieldError("username", "username 不能为空!"); } if (!ValidateUtil.isValidate(model.getPassword())) { addFieldError("password", "password 不能为空!"); } if (!identifyCode .toLowerCase() .equals(((String) (ActionContext.getContext().getSession().get("code"))).toLowerCase())) { addFieldError("identifyCode", "验证码不对!"); } if (hasErrors()) { return; } // 2.email被占用 if (userService.isRegisted(model.getEmail())) { addFieldError("email", "email 已经存在!"); } }