Struts Upgrade to 2.5.5 ( from 2.5.3)

无人久伴 提交于 2020-01-05 07:35:16

问题


I tried to upgrade from struts 2 version 2.5.3 to 2.5.5... I face an strange issue.

We have a tag as below:

<%@tag description="Rensders an ajax link"   pageEncoding="UTF-8"%>

<%@attribute name="parameters" description="list of parameters that put to this link"
    type="java.util.HashMap" required="false"%> 

       ..............
        <c:forEach items="${parameters}" var="p">
                <c:param name="${p.key}" value="${p.value}"/>
        </c:forEach>

The above code throws exception when I upgrade !

Caused by: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in &lt;forEach&gt;
    at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:274)
    at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:238)
    at org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(ForEachSupport.java:155)
    at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:256)
    at org.apache.jsp.tag.web.html.link_tag._jspx_meth_c_005fforEach_005f0(link_tag.java:439)
    at org.apache.jsp.tag.web.html.link_tag._jspx_meth_c_005furl_005f0(link_tag.java:405)
    at org.apache.jsp.tag.web.html.link_tag._jspx_meth_sec_005fauthorize_005f0(link_tag.java:366)
    at org.apache.jsp.tag.web.html.link_tag.doTag(link_tag.java:230)

As you see the tag is a JSTL tag not struts !

I use Tomcat 8.0 . Any comments.


回答1:


Surprisingly the parameters name which I used in my tag has a conflict with struts 2. It seems that this version of struts has defined a parameters in the context, which made a name conflict.

When I test ${parameters} in a jsp struts 2.5.3 I see noting

When I test ${parameters} in a jsp struts 2.5.5 I see org.apache.struts2.dispatcher.HttpParameters

So I renamed may tag attribute to params and everything is fine!



来源:https://stackoverflow.com/questions/40327981/struts-upgrade-to-2-5-5-from-2-5-3

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