Struts2 'Required' field Validation Interceptors not working

后端 未结 1 1581
南笙
南笙 2020-12-21 10:03

Building a login application (In Netbeans 731) which basically ensures non blank values for username and pw. The application runs fine except the validation doesn\'t work, s

相关标签:
1条回答
  • 2020-12-21 10:48

    Required validator is a basic validator type and it checks for null field values. If you enter blank characters to the input fields it may not work. Use requiredstring validator instead.

    <field name="userName">
        <field-validator type="requiredstring">
            <message>Please enter a user name</message>
        </field-validator>
    </field>
    <field name="password">
        <field-validator type="requiredstring">
            <message>Please enter a password</message>
        </field-validator>
    </field>
    

    The action class extends ActionSupport, it has default implementation of the Action interface required to return result after the action execution. And package extends struts-default that has <default-interceptor-ref name="defaultStack"/> and it inherited to your package.

    Also, the FilterDispatcher is deprecated since Struts 2.1.3.

    0 讨论(0)
提交回复
热议问题