驗證郵箱格式的正則表達式(Struts)

          Posted on 2006-12-28 11:58 閱讀(1304) 評論(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;
          ??? }

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 峡江县| 龙川县| 邵阳县| 吉林省| 闵行区| 吉木萨尔县| 兰西县| 灵台县| 民县| 崇州市| 苏尼特左旗| 平定县| 凭祥市| 花莲县| 周宁县| 萝北县| 沂南县| 翁源县| 四会市| 揭西县| 万安县| 彩票| 油尖旺区| 吉木萨尔县| 福州市| 新平| 千阳县| 惠东县| 家居| 三门峡市| 包头市| 文山县| 通辽市| 广水市| 无锡市| 曲阜市| 宜川县| 博湖县| 金溪县| 利辛县| 襄樊市|