Item value in JSTL foreach loop not working in Portlet

…衆ロ難τιáo~ 提交于 2019-12-08 03:06:08

问题


Given the following Portlet Code:

ArrayList nameList = new ArrayList();
nameList.add("Willi Willisch");
nameList.add("Seppi Seppisch");

renderRequest.setAttribute("names", nameList);

And the following JSP Code:

<c:forEach var="aName" items="${names}">
    <tr>
       <td>${aName} </td>
    </tr>

</c:forEach>

Prints out:

${aName}
${aName}

I don't have any clue why a $(aName) isn't evaluated. The forEach loops works, because ${aName} is printed out twice ....


回答1:


<c:out value="${aName}"/> works!! But shouldn't ${aName} work aswell?

Thus, "EL in template text" doesn't work? That can have one or more of the following causes:

  1. Application server in question doesn't support JSP 2.0.
  2. The web.xml is not declared as Servlet 2.4 or higher.
  3. The @page is configured with isELIgnored=true.
  4. The web.xml is configured with <el-ignored>true</el-ignored> in <jsp-config>.

To fix one or other, obviously do:

  1. Upgrade server or use JSTL c:out instead and live with it.
  2. Preferably declare web.xml to latest Servlet API version supported by appserver.
  3. Remove the isELIgnored=true attribute.
  4. Remove the <el-ignored>true</el-ignored> entry.


来源:https://stackoverflow.com/questions/2536333/item-value-in-jstl-foreach-loop-not-working-in-portlet

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