在JSP中,可以使用如下方法来判断session是否为空:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...
<c:if test="${empty session}">
Session为空
</c:if>
<c:if test="${not empty session}">
Session不为空
</c:if>
<% if (session != null) { %>
Session不为空
<% } else { %>
Session为空
<% } %>
无论使用哪种方法,都可以判断session是否为空。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:mysql 判断是否为空