目前在做的一个web项目,前端采用了jsp做展示,因为是做的是后台管理系统,对前端要求没那么高,所以采用了frame这种快被时代抛弃的布局模式,废话少说,直接上代码
<frameset rows="100,*" frameborder="no" border="0" framespacing="0">
<frame src="module/head.jsp" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" marginwidth="0" marginheight="0"/>
<frameset id="shrink" cols="200,*" class="frame" frameborder="no" border="0" framespacing="0">
<frame src="module/left.jsp" name="leftFrame" noresize="noresize" id="leftFrame" title="leftFrame" marginwidth="0" marginheight="0"/>
<frame src="module/user/search.jsp" name="mainFrame" noresize="noresize" id="mainFrame" title="mainFrame" marginwidth="0" marginheight="0"/>
</frameset>
</frameset>
大体上就是分了三块
1、header网页头部显示
2、left 菜单栏的位置
3、主展示页面,菜单栏的跳转页面,跳到此页面下做显示。
现在菜单栏类的所有超链接的跳转页面都是在right中做显示, right中的jsp中的超链接,也会在right中显示,也就是说跳不出这个框架。
问题场景:现在后台配置了一个登录过滤器用来拦截所有的jsp页面,防止用户没登录但能访问页面的情况出现,如果用户未登录,则跳转到login.jsp。在测试过程中,出现这样一个问题,在用户登录进系统后,right页面停留在查询用户的jsp上面,该页面有个查询按钮,此时服务器停止,重新启动,再次点击此按钮后,页面正常跳转到login.jsp但是却在right中打开,而没有跳出框架。
解决办法:修改过滤器,当用户未登录时,定位到一个新的jsp页面,这个页面不在框架中,然后在这个页面中用js跳转到登录页面代码:window.top.location.href='../login/login.jsp, (Top属性返回当前窗口的最顶层浏览器窗口。)就是起到一个过渡作用,就能跳出框架