如何解决服务器端重定向登陆页面内嵌框架的问题

  今天在做springmvc 的一个的登录合法性校验的需求时,重定向后的页面老是内嵌在框架中,这个在我以前的项目中没有遇到个这个问题,于是作为开发经验不是那么丰富的我来讲,最好的方法就是不断的百度了,好在最后问题完美的解决了。
 首先我们必须明白,现在的前端框架,大部分都是把页面组合在一个个的frame 中,因此,好的解决方法就是利用js代码跳出原来的框架结构。
         window.open('xxx',_top)

         window.open('xxx',_parent)
         window.parent.location.href('xxx',_top)
         window.open(''xxx);
          我在Interceptor 中的实际解决代码:
          PrintWriter out = response.getWriter();
               out.println("<html>");
               out.println("<script>");
                out.println("window.parent.open ('" + request.getContextPath()+"/vo/login.jsp','_self')");
               out.println("</script>");
               out.println("</html>");

猜你喜欢

转载自blog.csdn.net/qq_38061755/article/details/79837152