This question already has an answer here:
How to use the JSTL “if” tag without getting “..attribute test does not accept any expressions” [duplicate]
                                
                                    (1个答案)
                                
                        
                                5年前关闭。
            
                    
我的大学项目中有这个jsp文件,当尝试运行它时,出现此错误:根据标记文件中的TLD或属性指令,属性测试不接受任何表达式。我应该怎么做才能解决?感谢您的赞赏。

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Chat Joined</title>
  </head>

 <body>
<c:if test="${pageContext.request.method=='POST'}">   <-- here error happens
  <c:choose>
    <c:when test="${param.send!=null}">
      <c:set var="chat"
      value="${chat}<b>${param.uid}:</b>${param.text}<br />"
       scope="application" />
    </c:when>

    <c:when test="${param.clear!=null}">
      <c:set var="chat" value="" scope="application" />
    </c:when>
  </c:choose>
</c:if>

<table border="0">
  <tbody>
    <tr>
      <td>
        <h3>User:
        <c:out value="${param.uid}" />
        </h3>

        <hr />
      </td>
    </tr>

    <tr>
      <td>
        <c:out value="${chat}" escapeXml="false" />
      </td>
    </tr>

    <tr>
      <td>
        <hr />

        <form method="post">Message:
        <input type="text" name="text" size="20" />

        <input type="submit" name="send" value="Send" />

        <input type="submit" name="refresh" value="Refresh" />

        <input type="submit" name="clear" value="Clear" />

        <input type="hidden" name="uid"
        value="<c:out value="${param.uid}"/>" />

        <br />
        </form>
      </td>
    </tr>
  </tbody>
</table>

最佳答案

尝试在声明中使用此内容,而不是现在使用的内容

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

关于java - 根据TLD标签测试必须为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28948947/

10-12 04:06