The form:form tag declares that it accepts dynamic attributes but does not implement the required interface

折月煮酒 提交于 2020-01-02 15:26:32

问题


I have this code in my JSP:

<form:form commandName="Recipient" name="mailForm" 
           action="MailSuccess.jsp" method="get">
    <form:input path="toAddress"/>
    <form:input path="subject"/>
    <input type="submit" value="Send"/>
</form:form>

I am getting this error:

org.apache.jasper.JasperException: /SendMail.jsp(12,0) The form:form tag declares that it accepts dynamic attributes but does not implement the required interface

My guess is that I am missing some JAR file, but I am not sure. Can anyone provide some information for why this might happen?


回答1:


You are indeed missing some JAR files or maybe you have them but are of the wrong version (I'm thinking the Spring jars that contain the tag handlers are wrong, maybe even wrongly included jsp-api.jar in your application).

You get that exception from the servlet container because it considers the Spring Form tag handler invalid.

In JSP 2.0 there is a new feature added to tag handlers that allow them to take dynamic attributes. For that to happen, you have to specify it in the TLD file with a <dynamic-attributes>true</dynamic-attributes> declaration and your tag handler class must implement the DynamicAttributes interface.

From the exception, its likely that your application loaded a JSP 2.0 Spring TLD file combined with an old version of the JAR that contains the org.springframework.web.servlet.tags.form.FormTag class.

You are not mentioning the Spring version you are using. Is it 3? Maybe it loaded a Spring 2 JAR which might happen if you are using Maven to get your application dependencies. That will make sense because the classes changed in between versions, so this will be the first thing I will check:

FormTag version 2: All Implemented Interfaces: Serializable, IterationTag, JspTag, Tag, TryCatchFinally, EditorAwareTag.

FormTag version 3: All Implemented Interfaces: Serializable, DynamicAttributes, IterationTag, JspTag, Tag, TryCatchFinally, EditorAwareTag.



来源:https://stackoverflow.com/questions/13648357/the-formform-tag-declares-that-it-accepts-dynamic-attributes-but-does-not-imple

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!