1. Join the Validator plugin in the struts-config.xml file, add this plug-in, your app is not using the Validator environment, however, you want to use it if you need other configurations. Such as:
For example: When you need the "user name" on the page, you can't empty (that is, the ErrorS.Required), this {0} represents "User Name", so if you don't fill in the username, you will throw the following error: User Name is required. (You can modify Chinese as needed) We may have noticed that since the error prompt information needs to be configured, how is the "User Name" system in the above example? That's right! Also modify this configuration file, the content is as follows: visitcust.ror.name.Required =
Username This When "User Name" is empty, the Struts background program defines the unreasonable or more. In addition, the above "VisitCust.Name.Required" is specified when Validation.xml configures authentication content. See the following description. Note: In general, your system only needs an ApplicationResources file, so members of the development group do not add their own resource files. You only need to use multiple ApplicationResources files when your project group is developed, but your Struts-config.xml file will have the same number. 3. Create your ActionForm and let it inherit the org.apache.struts.validator.validatorform class. 4. Create your Action implementation and associate with the ActionForm defined above. It should be noted here that it must be set to True when defining this action, and does not implement its validate method in your defined actionform - this means you will use the ValidatorForm's validate method, so you can guarantee you Error verification is normal. 5. Configure the validation.xml file. The basic content is as follows: