Posted on 2006-12-28 18:56
路易 閱讀(2901)
評論(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;
??? }