The form:form tag declares that it accepts dynamic

2019-05-21 11:59发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-05-21 12:31

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.

查看更多
登录 后发表回答