在登录页面的onload方法中加入以下代码解决: //防止登录页面嵌入iframe框架 if (top.location != self.location){ top.location=self.location; } 其实这么做也不是很完美,因为要加载两次页面,屏幕会有些卡顿: 还有一种方法: 直接在过滤器LoginFilter中,加入以下代码: PrintWriter out = response.getWriter(); out.write("<script>window.pa…
在登录页面中添加js判断当前页面是否是父页面,诺不是则父页面跳转至登录页面. <script type="text/javascript"> //解决登录后多个父窗体问题 window.onload=function(){ if (window.parent != window) { window.parent.location.href="${pageContext.request.contextPath}/login.jsp"; } } </s…
需求:session超时时,返回登录页面,由于页面嵌套在iframe下,因此要跳转到登录页面的父页面,但是首页,登录页面等不需要进行跳转 实现: java文件:SessionIterceptor.java import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionInvocation;import com.opensymphony.xwork2.interceptor.AbstractInt…
在前台登录页面中加入JS代码,判断登录页面是否在iframe中,在iframe中就跳转出去 例: //判断是否在iframe中,在里面就跳出去 if (top.location.href != location.href) { top.location.href = '${base}/login.jhtml'; } 这种情况下会出现iframe中先嵌套登录页面然后才会跳转出去,也是可以解决的,把这段代码放在最上面,就是引入css后就引入这段代码,js 的暂停加载,就可以解决这个问题…
在login页面中添加以下一段代码:   var _topWin = window;  while (_topWin != _topWin.parent.window) {       _topWin = _topWin.parent.window;  }  if (window != _topWin)_topWin.document.location.href = '${base}/main/login'; …
将后台跳转改写成 PrintWriter out = response.getWriter(); out.println("<html>");    out.println("<script>");    out.println("window.open ('"+request.getContextPath()+"/login','_top')");    out.println("</…
springmvc控制登录用户session失效后跳转登录页面,废话不多少了,具体如下: 第一步,配置 web.xml <session-config> <session-timeout>15</session-timeout> </session-config> 第二步,配置spring-mvc.xml <!-- Session失效拦截 --> <mvc:interceptors> <!-- 定义拦截器 --> <…
当登录的Session失效后,采用ajax请求数据时会没有反应,这时候应该自动跳转到登录页面,让用户重新登录. 全局配置以下可实现 $(function() { $.ajaxSetup({ complete:function(XMLHttpRequest,textStatus){ if(textStatus=="parsererror"){ window.location.href = '../login.html'; } else if(textStatus=="error…
在项目中,经常会遇到session失效后,点击任何链接无反应的情况!这样给客户的体验就不是很好,以为是系统出了故障!所以在项目中我们会处理session失效后的跳转问题(一般给用户提示,并跳转后登录页面),代码实现如下所示: // 着重处理ajax请求跳转的问题,因为form表单请求可以直接在服务器端完成跳转 $.ajaxSetup({ contentType:"application/x-www-form-urlencoded;charset=utf-8", cache:false,…
session 过期返回登录页面 方法1, HttpSession session = request.getSession(); String LOGIN_ID = (String) session.getAttribute("LOGIN_ID"); if (null == LOGIN_ID||"".equals(LOGIN_ID)) { java.io.PrintWriter out = response.getWriter(); out.println(&qu…