Java struts page verification settings

Source: Internet
Author: User
1. Add the following in the struts-config.xml: Code

< Plug-in Classname = "Org. Apache. Struts. validator. validatorplugin" >
< Set-Property Property = "Pathnames" Value = "/Org/Apache/struts/validator/validator-rules.xml,/WEB-INF/validations. xml" />

</ Plug-in >

2. Create validations. xml under the WEB-INF. Assume that the verified form is named inputform, the verification name, title, content cannot be blank, the Code is as follows:

<? XML version = "1.0" encoding = "UTF-8" ?>
<! Doctype form-validation public
"-// Apache Software Foundation // DTD commons validator rules configuration 1.3.0 // en"
Http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd" >
< Form-validation >
< FormSet >

< Form Name = "Inputform" >
< Field Property = "Name" Depends = "Required" >
< MSG Name = "Required" Key = "Guest. inputform. Name" />
</ Field >
< Field Property = "Title" Depends = "Required" >
< MSG Name = "Required" Key = "Guest. inputform. Title" />
</ Field >
< Field Property = "Content" Depends = "Required" >
< MSG Name = "Required" Key = "Guest. inputform. Content" />
</ Field >

</Form>

</FormSet>

</Form-validation>

 

3. Set the resource file for display information

Guest. inputform. content = content is null
Guest. inputform. Name = Name Is null
Guest. inputform. Title = title is null

4. Add <HTML: javascript formname = "inputform"/> in front of the JSP file and modify <HTML: Form Action = "/input">, change to <HTML: Form Action = "/input" onsubmit = "Return validateinputform (this)">

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.