Struts 1.1 Can Validate integer, long, etc. Just put convertNull to true

L

liu

Recently I had some quality frustration time with Struts 1.1
validation on integer, long, etc. Since I pass the whole Data Transfer
Object into the dynaValidatorForm, it is not easy for me to set Long
parameter to String and do conversion in Action class. By default
configuration, even though I set up the validation to be "required,
long", the validator did not block invalid input and caused exception.
I found Greg Williams ([email protected]) had the same
problem.
In Struts document, there is a paragraph:

Note: If your required form property is one of the Java object
representations of primitive types (ie. java.lang.Integer), you must
set the ActionServlet's convertNull init. parameter to true. Failing
to do this will result in the required validation not being performed
on that field because it will default to 0.

After I add the parameter "convertNull" in web.xml, I have everything
behaving as expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top