Posted on 2006-12-28 11:58
鹭 阅读(1297)
评论(0) 编辑 收藏
public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest httpServletRequest) {
String style =
"^[a-zA-Z][a-zA-Z0-9._-]*@([a-zA-Z0-9-_]+\\.)+(com|gov|net|com\\.cn|edu\\.cn)$";
Pattern ptt = Pattern.compile(style);
Matcher mch=ptt.matcher(email);
ActionErrors errors = new ActionErrors();
if ((name == null || name.equals(""))) {
ActionError error = new ActionError("error.name");
errors.add("name", error);
} else
if (!mch.matches()) {
ActionError error = new ActionError("error.email");
errors.add("email", error);
}
return errors;
}