Home » struts 2 double validation example

struts 2 double validation example

by Online Tutorials Library

Struts 2 double validation example

The double validator checks that given floating-point number is within the specified range. It can be used in product price etc.

Parameters of double validator

There is 5 parameters defined for double validator.

Parameter Description
fieldName specifies the field name that is to be validated. It is required in Plain-Validator only.
minInclusive specifies the minimum inclusive value. It is ignored bydefault.
maxInclusive specifies the maximum inclusive value. It is ignored bydefault.
minExclusive specifies the minimum exclusive value. It is ignored bydefault.
maxExclusive specifies the maximum exclusive value. It is ignored bydefault.

Example of double validator

Full example of double validator

1) Create index.jsp for input

This jsp page creates a form using struts UI tags. It receives name, password and email id from the user.

index.jsp

2) Create the action class

This action class inherits the ActionSupport class and overrides the execute method.

RegisterAction.java

3) Create the validation file

Here, we are using bundled validators to perform the validation.

Register-validation.xml

4) Create struts.xml

This xml file defines an extra result by the name input, and an interceptor jsonValidatorWorkflowStack.

struts.xml

5) Create view component

It is the simple jsp file displaying the information of the user.

welcome.jsp

You may also like