Posted on 2006-12-28 18:56
路易 阅读(2895)
评论(2) 编辑 收藏 所属分类:
STRUTS
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;
}