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

📄 checkpetaction.java

📁 网上电子宠物系统
💻 JAVA
字号:
package com.zc.struts.Action;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.zc.PetProject.VO.PetInfoVO;
import com.zc.struts.Services.CheckPetService;
import com.zc.struts.form.CheckPetForm;

public class CheckPetAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		request.setCharacterEncoding("UTF-8");
		CheckPetForm petform=(CheckPetForm)form;
			//判断验证码~!
		ActionErrors errors=new ActionErrors();
		String checknum=request.getSession().getAttribute("rand").toString();
		String num=request.getParameter("input_txt").toString();
		if(!checknum.equals(num)){
			errors.add("",new ActionError(""));
			this.saveErrors(request, errors);
			return new ActionForward(mapping.getInput());
		}
		
		PetInfoVO pet=new CheckPetService().CheckPet(petform.getPetname(), petform.getpetpassword());
		if(pet!=null){
			request.getSession().setAttribute("pet",pet);
			return mapping.findForward("index");
		}
		return mapping.findForward("error");
	}
}

⌨️ 快捷键说明

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