JSPforEach标签报错:AccordingtoTLDorattributedirectiveintagfile,attributeitemsdoesnotacceptanyexpressions

star2017 1年前 ⋅ 397 阅读

问题

JSP 在使用forEach标签时报错:According to TLD or attribute directive in tag file, attribute items does not accept any expressions。

原因

原因:web.xmlweb-app_2_5.xsd版本大于2.3,需要使用jstl的扩展标签。

解决

解决:jsp文件引用的jstl core标签库改为扩展标签库,
将:<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
替换成:<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
差异:2.5版本可以根据索引 ID 取出 List 里的单个值, 2.3版本就不行。

<body>
    <!-- 从list集合中根据索引位取值 -->
    <h3>${list[0] }</h3>
    <h3>${list[1] }</h3>
    <h3>${list[2] }</h3>
    <h3>${list[3] }</h3>
</body>
更多内容请访问:IT源点

相关文章推荐

全部评论: 0

    我有话说: