Use of validate () and validatexxx in struts
After learning Struts2, you will find that validate is not in the past! How does it come true?
Validate and Validatexxxx are all interceptor implementations! In an action, if you call the inside method, you will call the Validate method. And if there is validatexxxx this method. Depends on you call now is not XXXX!
For example, the login method (in action) is now called outside. The order is: Validatelogin->validate->login
Note: The first letter of the 1.validateXxxxvalidate is capitalized. Otherwise, it's an ordinary way.
2. There must be a Addfielderror method in the ValidateXxx and validate methods
3. In Struts-xml, use <result name= "input" >/login</result> ( This verifies that the error will return to the original interface, and when Addfielderror gets the value, it returns input to Struts-xml. And does not run the login method. Of course, if you can Ajax, it's not necessary.)
Use of validate () and validatexxx in struts