项目后台判断session过期的页面代码

checksession.jsp

<%@page import="com.bn.car.core.Constants"%>
<%@page import="com.bn.car.biz.sysadmin.dto.SysAdminInfoDTO"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%> <% SysAdminInfoDTO dto = (SysAdminInfoDTO)session.getAttribute("sysAdminInfoDto");
// ////ln("include page println....");
if(dto == null){
%>
<script type="text/javascript">
window.parent.location.href="<%=Constants.ROOT%>property/index.jsp";
alert("非法访问!!请登录后台系统!!");
</script>
<%
return;
}
%>

在后台引用该jsp页面:

<jsp:include page="include/checksession.jsp" ></jsp:include>

使用了frameset,需要使用window.parent来跳转。~!
跳转的路径最好写成绝对路径才保证,相对路径在某些场合的情况下往往不可信。~!

上一篇:jQuery倒计时


下一篇:【Java学习笔记】foreach语句(高级for)