标记 <c:if> 无效

Tag <c:if> doesn't work

我有方法获取 Cookie,并将返回的布尔值与 进行比较,但它不起作用。两种情况都不成立。

static public boolean isUserAuth(HttpServletRequest request){
        String cookieName = "forum_login";
        Cookie cookies [] = request.getCookies ();
        Cookie myCookie = null;
        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                if (cookies[i].getName().equals (cookieName)) {
                    myCookie = cookies[i];
                    return true;
                }
            }
        }
        return false;
    }

JSP 页数:

<%@ page import="db_Proccesing.Users_processing" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    boolean test = Users_processing.isUserAuth(request);
%>

<!DOCTYPE html>

<header>
    <a class="header-logo"></a>

    <div id="form_text" class="form">
        <c:if test = "${test == true}">
        <p>TRUE</p>
        </c:if>
        <c:if  test = "${test == false}">
            <p>FALSE</p>
        </c:if>
    </div>
</header>

所以,不打印 TRUE 和 FALSE

我修复它,使用:

  <c:if test = "<%= !Users_processing.isUserAuth(request) %>">

谢谢大家。