⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkuserregaction.java

📁 一个简易的网上购物系统。具有普遍的购物功能。还有一个小型的论坛
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.longHua.web.struts;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


/** 
 * MyEclipse Struts
 * Creation date: 05-26-2008
 * 
 * XDoclet definition:
 * @struts.action parameter="method" validate="true"
 */
public class CheckUserRegAction extends BaseDispatchAction {

	public ActionForward checkUserRegName(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		//得到需要检查的用户名
		String userName=request.getParameter("userName");
		//判断用户名是否符合格式和用户名是否存在
		Pattern pattern=Pattern.compile("^\\w+$");
		Matcher matcher=pattern.matcher(userName);	
			PrintWriter out=null;
			try {
		        out = response.getWriter();
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(matcher.matches()){
			if(getLongHua().checkRegName(userName).size()!=0){
			    out.print("nameReg");
			 }else{
				out.print("nameNotReg");
			 }
			}else{
				out.print("nameReg");
			}
		return null;
	}
	
	public ActionForward checkUserRegMail(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		//得到需要检查的Email
		String userMail=request.getParameter("userMail");
		//判断Email格式是否正确和是否存在
		Pattern pattern=Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
		Matcher matcher=pattern.matcher(userMail);
		PrintWriter out=null;
		try {
	        out = response.getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		if(matcher.matches()){
		 if(getLongHua().checkRegEmail(userMail).size() !=0){
		    out.print("mailReg");
		 }else{
			out.print("mailNotReg");
		 }
		}else{
			out.print("mailReg");
		}
		return null;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -