I have a field “length” in one of my struts 2 form. The data-type of “length” is “double”. I have applied the “double” validation in XML file. But when I key-in alphabets in the “length” text field, it shows the error message as
Invalid field value for field "length"
I don’t want this message to be shown like this. This message is generated by struts 2 itself and not entered by me. I guess, this message comes as the conversion of data fails. I also applied the “conversion” validator, but the above error message is still showing up. Please suggest the solution.
Thanks in advance.
You’re in luck. This text is customizable.
The text is defined in xwork-messages.properties in the xwork jar. You can override it by adding the following to your global i18n resource bundle:
As you guessed, this error message occurs for all type conversion failures. The
XWorkConverterclass has some useful javadoc about this: