Struts2 "Input" represents the input page, what does it mean. That is, when the form is submitted or when the page is entered, the form is validated, an error or type conversion (such as in the age of the text box in addition to the number of other characters) error is returned to the input page, so use input to represent ....
There are two ways to enter a validation error that displays an error message:
1. Public String Login () {
if (User.getusername () ==null| | "". Equals (User.getusername ())) {
This.addfielderror ("username", "Can NOT NULL");
return INPUT;
}
return SUCCESS;
}
2. @Override
public void Validate () {
if (User.getusername () ==null| | "". Equals (User.getusername ())) {
This.addfielderror ("username", "Can NOT NULL");
return INPUT;
}
Super.validate ();
}
The second method is to override the Validate method without writing the return value input.