checkpetaction.java
来自「网上电子宠物系统」· Java 代码 · 共 40 行
JAVA
40 行
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 + =
减小字号Ctrl + -
显示快捷键?