How to realize the Null value judgment of objects in httpsession by JSTL by Thymleaf

<c:choose>
            <c:when test="${empty login}">
                <li><a href="../index/loginUI.do"><i class="fa fa-user"></i>/</a>
                </li>
            </c:when>
            <c:otherwise>
                <li><a href="../index/mycenter.do"><i class="fa fa-user"></i></a></li>
                <li><a href="../index/logout.do"><i class="fa fa-user"></i></a>
                </li>
            </c:otherwise>
        </c:choose>

this is what I wrote in JSTL, and it can run successfully without any exception

 <li><a th:href="@{/login/loginUI}" th:if="${-sharphttpSession.login}eq null"><i class="fa fa-user-md"></i></a>
            </li>
            <li><a th:href="@{/index/loginUI}" th:if="${-sharphttpSession.login}eq null"><i class="fa fa-user"></i>/</a>
            </li>
            <li><a th:href="@{/index/mycenter}" th:unless="${-sharphttpSession.login} eq null"><i class="fa fa-user"></i></a></li>
            <li><a th:href="@{/index/logout}" th:if="${-sharphttpSession.login} ne null"><i class="fa fa-user"></i></a>
            </li>

but I can never find login when I use it in thymleaf

then my java code

 @RequestMapping("/index")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        Page page = new Page("filter_form");
        page.setPageSize(8);
        String currentPage = request.getParameter("page.currentPage");
        if (StringUitl.IsNotNull(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }
        //map
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("page", page);
        List list = changguanService.getForPage(map);
        //
        request.setAttribute("list", list);
        request.setAttribute("paging", page.getPageStr());
        System.out.println(page.getPageStr());
        return new ModelAndView("index/index");
    }
 @RequestMapping("/login")
    public void login(HttpServletRequest request, HttpServletResponse response, HttpSession httpSession) throws IOException {
        String pwd = request.getParameter("pwd");
        String no = request.getParameter("no");
        response.setCharacterEncoding("utf-8");
        Login login = (Login) httpSession.getAttribute("login");
        if (login == null) {
            User user = userService.checkUserNo(no, pwd);
            if (user == null) {
                response.setContentType("text/html;charset=utf-8");
                response.getWriter().write("<script>alert("");</script>");
                response.getWriter().write("<script> window.location="../index/index" ;window.close();</script>");
                response.getWriter().flush();
            }
            login = new Login(user.getId(), user.getName(), "user", "");
            httpSession.setAttribute("login", login);
        }
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("<script>alert("");</script>");
        response.getWriter().write("<script> window.location="../index/index" ;window.close();</script>");
        response.getWriter().flush();
    }

how can thymleaf realize the problem of directly judging the null value of an uncreated object by jstl

Mar.06,2021

is too obsessed with the type of httpsession. After reading the document carefully, I found that session.login can get the value directly

.
        <li><a th:href="@{/login/loginUI}" th:unless="${session.login} ne null"><i class="fa fa-user-md"></i></a>
    </li>
        <li><a th:href="@{/index/loginUI}" th:unless="${session.login} ne null"><i class="fa fa-user"></i>/</a>
        </li>
        <li><a th:href="@{/index/mycenter}" th:if="${session.login}"><i class="fa fa-user"></i></a></li>
        <li><a th:href="@{/index/logout}" th:if="${session.login}"><i class="fa fa-user"></i></a>
        </li>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36cae-2c04e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36cae-2c04e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?