ActionErrors没有提示信息,这是我的 actionform :
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.Serializable;
public class OrderCarForm extends org.apache.struts.validator.ValidatorForm
implements Serializable {
private String errormessage;
private String password;
private String username;
public OrderCarForm()
{
}
public String getErrormessage()
{
return errormessage;
}
public void setErrormessage(String errormessage) {
this.errormessage = errormessage;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest)
{
/**@todo: finish this method, this is just the skeleton.*/
ActionErrors errors = new ActionErrors();
OrderCarForm form = new OrderCarForm();
try
{
if (username.equals("")) {
errors.add("username", new ActionError("username.errors"));
//errors.add(errors.GLOBAL_MESSAGE, new ActionMessage("username.errors"));
form.setErrormessage("用户名称不可以为空!");
//errors.add("error",new ActionMessage("用户名不可以为空!")) ;
}
if (password.equals(""))
errors.add("password", new ActionError("password.error"));
}
catch(Exception e)
{
System.out.println(e.getMessage() );
errors = null;
}
return errors;
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest)
{
}
}
这是我的 action ;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.commons.logging.Log;