91-9990449935 0120-4256464 |
Struts2 String Length Validation ExampleThe stringlength validator specifies that string must be of given length. It can be used in username, password etc. It trims the string bydefault then checks if its length is of the given length. Parameters of stringlength validatorThere are 4 parameters defined for stringlength validator.
Example of stringlength validatorFull example of stringlength validator1) Create index.jsp for inputThis jsp page creates a form using struts UI tags. It receives name, password and email id from the user. index.jsp2) Create the action classThis action class inherits the ActionSupport class and overrides the execute method. RegisterAction.java3) Create the validation fileHere, we are using bundled validators to perform the validation. Register-validation.xml4) Create struts.xmlThis xml file defines an extra result by the name input, and an interceptor jsonValidatorWorkflowStack. struts.xml5) Create view componentIt is the simple jsp file displaying the information of the user. welcome.jsp
Next TopicStruts2 Email Validation Example
|