小编典典

如何在不获取“ ..attribute测试不接受任何表达式的情况下”使用JSTL“ if”标记

jsp

我如何使以下代码起作用?

        <c:if test="${null != searchResults}" >
            <c:forEach items="${searchResults}" var="result" varStatus="status">

我已经尝试了许多不同的变化,例如:

<c:if test="${searchWasPerformed}" >

要么

<c:if test="<%=request.getAttribute("searchWasPerformed") %>" >

乃至

<% boolean b = null != request.getAttribute("searchResults"); %>
    <c:if test="${b}" >

看起来真的很丑:/但我继续

org.apache.jasper.JasperException: /WEB-INF/jsp/admin/admin-index.jsp(29,2) PWC6236: According to TLD or attribute directive in tag file, attribute test does not accept any expressions

我将如何解决?


阅读 908

收藏
2020-06-08

共1个答案

小编典典

检查您使用的JSTL taglib的版本。它应该是1.1,所以您应该拥有(请注意URI):

<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
2020-06-08