Struts String Length Field Validator XML

<field name="fieldName">
<field-validator type="stringlength">
<param name="param name">param value</param>
<message>validation error message</message>
</field-validator>
</field>

Struts 2 String Length Validation

The string length field validator makes sure that a string field’s length, such as a password’s 6–12 characters, stays within a certain range. Using the stringlength property in elements or annotation types may be applied to XML or annotations. The String will have at least that many characters if the minLength option is supplied. When the maxLength argument is used, the String will only have that many characters at maximum. It decides whether to trim the String before doing the length check based on the trim option. The String will be truncated if it is not supplied.

Similar Reads

Struts String Length Field Validator XML

param value validation error message ...

Steps to Create Struts 2 String Length Validation

Step 1: Create an index.jsp file to receive user input...

Contact Us