如何使用JSTL"if"标签未获得"..attribute测试不接受任何表达式" [英] How to use the JSTL "if" tag without getting "..attribute test does not accept any expressions"

查看:678
本文介绍了如何使用JSTL"if"标签未获得"..attribute测试不接受任何表达式"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How would I make the following code work?

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

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

I've tried many different variations of this, such as:

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

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

甚至

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

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

Which looks REALLY ugly :/ But I keep on getting the

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

我该如何解决?

推荐答案

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

Check version of JSTL taglib you use. It should be 1.1, so you should have (note the URI):

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

这篇关于如何使用JSTL"if"标签未获得"..attribute测试不接受任何表达式"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆