Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Validation > url validator
#editReport()

Description

URLValidator checks that a given field is a String and a valid URL

Parameters

  • fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required

Examples

    <validators>
         <!-- Plain Validator Syntax -->
         <validator type="url">
             <param name="fieldName">myHomePage</param>
             <message>Invalid homepage url</message>
         </validator>
         
         <!-- Field Validator Syntax -->
         <field name="myHomepage">
             <message>Invalid homepage url</message>
         </field>
    </validators>