In jstl <c: if> tag attribute usage

Today + el acquire property from the session with the domain jstl, encountered a problem

org.apache.jasper.JasperException: <h3>Validation error messages from TagLibraryValidator for [c] in [/login.jsp]</h3><p>2: Illegal scope attribute without var in "c:if" tag.</p><p>19: Illegal scope attribute without var in "c:if" tag.</p>
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81)
    org.apache.jasper.compiler.Validator.validateXmlView(Validator.java:1917)
    org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1863)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:224)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:385)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Sometimes the error when you refresh the page, sometimes not being given a bit ignorant, how I have been using the labels on the error?
Find the error message source

<c:if test="${count>=1&&count<3}" scope="session">
    <c:out value="<span>账号或密码错误</span><br/>" escapeXml="false"></c:out>
    <c:out value="<span>剩余登陆次数:${sessionScope.count}</span>" escapeXml="false"></c:out>
</c:if>

Where: count attribute has been placed in session field
to the next, might not mean count scope of the domain, if there is a label attribute is var, is used to store test result value, then the scope is not intended to represent a var scope?
Change the code

<c:if test="${sessionScope.count>=1&&sessionScope.count<3}">
    <c:out value="<span>账号或密码错误</span><br/>" escapeXml="false"></c:out>
    <c:out value="<span>剩余登陆次数:${sessionScope.count}</span>" escapeXml="false"></c:out>
</c:if>

Error Resolution!

Guess you like

Origin www.cnblogs.com/mlr-wjy/p/12048475.html