Http://www.cnblogs.com/dafanjava/archive/2011/08/02/2124681.html
Background note:
I'm using a struts2.2.3.
Related Source:
<s:form action= "Addbook" validate= "true" ><!--form label, enable validation--> plus validate= "true" to report the following error
<s:label value= "Form label" ></s:label>
<s:textfield name= "name" label= "title" ></s:textfield>
<s:textfield name= "Author" label= "author" ></s:textfield>
<s:submit value= "Submit" align= "Center" ></s:submit>
</s:form>
reported the following error:
Critical: Method public java.util.List org.apache.struts2.components.Form.getValidators (java.lang.String) threw Exception when invoked on org.apache.struts2.components.form@19c6163
method Public Java.util.List Org.apache.struts2.components.Form.getValidators (java.lang.String) threw a exception when invoked on org.apache.struts2.components.form@19c6163
The problematic instruction:
----------
==> List Tag.getvalidators ("${tagname}") as validator [on line +, column 9 in TEMPLATE/XHTML/FORM-CLOSE-VALIDATE.FTL]
in incl Ude "/${PARAMETERS.TEMPLATEDIR}/XHTML/FORM-CLOSE-VALIDATE.FTL" [on line], column 1 in TEMPLATE/XHTML/FORM-CLOSE.FTL]
----------
Java backtrace for programmers:
----------
Freemarker.template.TemplateModelException : Method public Java.util.List org.apache.struts2.components.Form.getValidators (java.lang.String) threw an exception When invoked on org.apache.struts2.components.form@19c6163
(Other detailed exception information is omitted here)
caused by:java.lang.NullPointerException
(Other detailed exception information is omitted here)
Serious: Servlet.service () for Servlet JSP threw exception
Java.lang.NullPointerException
(Other detailed exception information is omitted here)
Solution:
Law I:
Remove validate= "true"
But I don't think that's the way you want it (I don't want to solve it anyway), so I use the second approach.
Law II:
Change the Name property of the form label to "Addbook.action" to read: <s:form action= "Addbook.action" validate= "true" ></form>
Problem solved, but I don't know why I need to add. Action, please leave a message.