infoform.java

来自「基于struts开发的网上书店系统。希望对大家有帮助。JSP JavaBean 」· Java 代码 · 共 83 行

JAVA
83
字号
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package book;

import javax.servlet.http.HttpServletRequest;

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

/** 
 * MyEclipse Struts
 * Creation date: 09-19-2007
 * 
 * XDoclet definition:
 * @struts.form name="infoForm"
 */
public class InfoForm extends ActionForm {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method validate
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	  //这是映射bookinfo.jsp页面form内容的类
	  //需要验证提交的数据不能为空

	  private String dwelling;
	  private String email;
	  private String name;
	  public String getDwelling() {
	    return dwelling;
	  }
	  public void setDwelling(String dwelling) {
	    this.dwelling = dwelling;
	  }
	  public String getEmail() {
	    return email;
	  }
	  public void setEmail(String email) {
	    this.email = email;
	  }
	  public String getName() {
	    return name;
	  }
	  public void setName(String name) {
	    this.name = name;
	  }
	  public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
	    
	    ActionErrors errors = new ActionErrors();
	    if(dwelling == null || dwelling.length() < 1) 
	    {
	      errors.add("dwelling",new ActionError("hello.nopersonerror"));
	    }
	    if(name == null || name.length() < 1) 
	    {
	      errors.add("name",new ActionError("hello.nopersonerror"));
	    }
	    if(email == null || email.length() < 1) 
	    {
	      errors.add("email",new ActionError("hello.nopersonerror"));
	    }
	    return errors;
	    
	  }
	  
	  public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
	  
	    this.dwelling=null;
	    this.name=null;
	    this.email=null;
	  
	  }
	}

⌨️ 快捷键说明

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