Struts 2 email validator

The email validator is used check that the String field is a valid email address and it should not be empty. Plain validator syntax of email validator. <validators> <validator type="email"> <param name=”fieldName">fieldName</param> <message>message string</message> </validator> </validators><validators> <validator type="email"> <param name=”fieldName">fieldName</param> <message>message string</message> </validator> </validators> Field validator syntax of requiredstring validator. <validators> <field name="fieldName"> <field-validator type="email"> … Read more

Struts 2 date validator

The required validator is used check that the date is within a specific range. Plain validator syntax of date validator. <validators> <validator type="date"> <param name=”fieldName">fieldName</param> <param name="min">minDate</param> <param name="max">maxDate</param> <message>message string</message> </validator> </validators><validators> <validator type="date"> <param name=”fieldName">fieldName</param> <param name="min">minDate</param> <param name="max">maxDate</param> <message>message string</message> </validator> </validators> Field validator syntax of date validator. <validators> <field name="fieldName "> … Read more

Struts 2 double validator

The double validator is used check that the double is within a specific range. Plain validator syntax of double validator. <validators> <validator type="double"> <param name=”fieldName">fieldName</param> <param name="min">minDouble</param> <param name="max">maxDouble</param> <message>message string</message> </validator> </validators><validators> <validator type="double"> <param name=”fieldName">fieldName</param> <param name="min">minDouble</param> <param name="max">maxDouble</param> <message>message string</message> </validator> </validators> Field validator syntax of double validator. <validators> <field name="fieldName"> <field-validator … Read more

Struts 2 int validator

The int validator is used check that the integer is within a specific range. Plain validator syntax of int validator. <validators> <validator type="int"> <param name=”fieldName">fieldName</param> <param name="min">minInt</param> <param name="max">maxInt</param> <message>message string</message> </validator> </validators><validators> <validator type="int"> <param name=”fieldName">fieldName</param> <param name="min">minInt</param> <param name="max">maxInt</param> <message>message string</message> </validator> </validators> Field validator syntax of int validator. <validators> <field name="fieldName "> … Read more

Struts 2 stringlength validator

The stringlength validator is used check that the length of the string field is within a specified range. Plain validator syntax of stringlength validator. <validators> <validator type="stringlength"> <param name="fieldName">fieldName</param> <param name="minLength"> minLength</param> <param name="maxLength"> maxLength</param> <param name="trim">true</param> <message>message string</message> </validator> </validators><validators> <validator type="stringlength"> <param name="fieldName">fieldName</param> <param name="minLength"> minLength</param> <param name="maxLength"> maxLength</param> <param name="trim">true</param> <message>message string</message> … Read more

Struts 2 requiredstring validator

The required validator is used check that the specified string field can’t be null and should have length greater than 0. Plain validator syntax of requiredstring validator. <validators> <validator type="requiredstring"> <param name="fieldName">fieldName</param> <param name="trim">true</param> <message>message string</message> </validator> </validators><validators> <validator type="requiredstring"> <param name="fieldName">fieldName</param> <param name="trim">true</param> <message>message string</message> </validator> </validators> Field validator syntax of requiredstring validator. <validators> … Read more

Struts 2 required validator

The required validator is used check that the specified field can’t be null. Plain validator syntax of required validator. <validators> <validator type="required"> <param name="fieldName">fieldName </param> <message>message string</message> </validator> </validators><validators> <validator type="required"> <param name="fieldName">fieldName </param> <message>message string</message> </validator> </validators> Field validator syntax of required validator. <validators> <field name="fieldName "> <field-validator type="required"> <message>message string</message> </field-validator> </field> </validators><validators> … Read more

Struts 2 validation by built-in validators

Struts 2 validation framework provides many generic built-in validators to perform various validations like email validation, required validation, stringlength validation etc. These validations are also known as XML based validation. Built-in validators are placed in an xml file. The name of the xml file should be like actionClassName-validation.xml. Note: No need to specify any validate() … Read more

Struts 2 validation framework

Validation: Validation is a process of checking something against a standard. Struts 2 validation framework: Struts 2 validation framework provides many generic built-in validation methods or validators to perform various validations. It enables the web container to perform validation rules before executing the actions. We can also create custom validators. Ways of performing validations in … Read more

Struts 2 Redirect result type

Redirect result type: Redirect result type creates a new request by calling response.sendRedirect() method. Struts 2 Redirect result type example: login.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 redirect result type example</title> </head> <body> <h3>This is a redirect result type example.</h3>   <s:form action="Login"> <s:textfield name="userName" label="UserName" /> <s:submit value="Hello" align="center"/> </s:form>   </body> … Read more