The first type:
As long as the action class inherits the Actionsupport, you can use the validation scheme.
It's a primitive solution, it needs to write code, but it's very flexible, login case
Insufficient: The code for Business processing and validation is mixed together, which makes it inconvenient to verify the reuse and maintenance of the part
@Overridepublic String Execute () throws Exception {User user=userservice.getuser (loginName), if (user==null) { Addfielderror("LoginName", GetText ("Invalid.loginname"));//correspondence <s:fielderror/>//Display field-related error messages
//addactionerror corresponds to <s:actionerror/> displays all information about the action return input;//indicates the need to re-enter}else if (! User.getpassword (). Equals (password)) {addfielderror ("password", GetText ("Invalid.password")); return INPUT;} Else{sessionmap.put ("user", user); return SUCCESS;}}
The second type:
Overriding the Validate () method
Business and data separation
Insufficient: Before the business method is called, when the Validate () method validation does not pass, then the validation method of the action class will not be executed, that is, validate () also tube action all validation, if you want to validate a single business method is not
The third type:
Vlidatexxx () validation
Xxx () is written to be specific to a particular method
Verification with Actionsupport implementation