jsp中获取session

2017-07-14  本文已影响0人  cherchao

// 不推荐使用
<%
if(session.getAttribute("userInfo") == null) {
response.sendRedirect("./login.jsp");
}
%>

// 使用El表达式
function checkLogin() {
var uid = "${userInfo.id}"; // 需要添加引号
if (uid == 0) {
window.location.href = "./login.jsp";
}
};

// 不需要引号
<span class="dl-log-user">${userInfo.username}</span>

上一篇下一篇

猜你喜欢

热点阅读