Use of validate () and validatexxx in struts

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.