📄 customerform.java
字号:
package struts.example;
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;
/**
* <p>Title: Eclipse Plugin Development</p>
* <p>Description: Free download</p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: Free</p>
* @author gan.shu.man
* @version 1.0
*/
public class CustomerForm extends ActionForm
{
/** Customer First Name */
private String firstName;
/** Customer Last Name */
private String lastName;
private String step;
public CustomerForm()
{
firstName = "";
lastName = "";
}
public String getFirstName()
{
return firstName;
}
public void setFirstName(String s)
{
this.firstName = s;
}
public String getLastName()
{
return lastName;
}
public void setLastName(String s)
{
this.lastName = s;
}
public String getStep()
{
return step;
}
public void setStep(String string)
{
step = string;
}
/**
* 主要功能是验证CustomerForm的有效性
* 如果struts-config.xml配置中设置validate=true
* 当CustomerForm被创建后,此方法被RequestProcessor调用
* @return 返回ActionErrors的信息
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
//Firstname不能为空
if (firstName == null || firstName.trim().equals(""))
{
errors.add("firstName", new ActionError("error.cust.firstname.empty"));
}
//Lastname不能为空
if (lastName == null || lastName.trim().equals(""))
{
errors.add("lastName", new ActionError("error.cust.lastname.empty"));
}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -