STRUTS2 form label plus validate= "true" for the wrong solution __struts2

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.