response.sendRedirect和html frame配合使用的问题
来源:互联网 发布:终极火力辅助源码 编辑:程序博客网 时间:2024/05/08 20:31
目前正在做一个web项目,在其中大量的使用了html frame。主要是为了解决局部刷新。但是随之一个有趣的问题就来了。为了防止未登录用户使用程序,在应用中使用了一个filter,用来判断用户是否登录,如果没有就转向到登录页面。原来是使用response的sendRedirect来重新定位,但是由于使用了frame,那么在给后台发送请求时,实际的请求是在frame所包含的页面中发出的。这样一来,原本单独成页的登录页面就被包含到了这个frame中,完全和预想的不一样!!
如果在html页面中,这样的问题可以通过链接的target属性来解决,然而在response中并没有地方让我们指定目标的target。如何解决呢?一种方式就是做一个jsp,在jsp使用js来重定向链接到真正的登录页面,此时我们可以有机会使用target属性。然后在filter中定向到这个jsp。然而这样多出来的页面,给人感觉终究不爽。但是这样有启发我们可以这样做,请看代码:
java.io.PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<script>");
out.println("window.open ('/fog/index.htm', '_top')");
out.println("</script>");
out.println("</html>");
对了,我们仍然使用方法一的思想,但是使用response直接生成方法一的中间页。这样岂不更爽?!当然,如何浏览器禁用js,那我也没辙了,如有更好的方法,希望能告知。
- response.sendRedirect和html frame配合使用的问题
- response.sendRedirect和html frame配合使用的问题
- iframe和response.sendRedirect使用的问题
- iframe和response.sendRedirect使用的问题
- iframe和response.sendRedirect使用的问题
- iframe和response.sendRedirect使用的问题
- 使用response.sendRedirect()时的中文问题
- response.sendRedirect的使用
- response.sendRedirect的使用
- 使用response.sendRedirect的注意事项。
- requestdispatcher.forward 和response的sendredirect的路径问题
- servlet如何选择request.getRequestDispatcher和response.sendRedirect的使用
- 解决response.sendRedirect引出的中文问题
- 有关jsp中的response.sendRedirect()的问题
- response.sendRedirect() 的session丢失问题
- 有关jsp中的response.sendRedirect()的问题???
- JSP的response.sendRedirect()中文参数问题
- response.sendRedirect() 的session丢失问题
- 使用ant编译、运行junit、以及检查编码
- 简化JDBC的使用(1)
- 简化JDBC的使用(2)
- Struts Validation框架浅尝1
- Struts Validation框架浅尝2
- response.sendRedirect和html frame配合使用的问题
- junit使用简明手册
- EasyMock使用简明手册
- JunitPerf使用简明手册
- StrutsTest使用简明手册
- JCoverage使用简明手册
- 标准模板库
- 标准模板库简介(二)
- 日誌的學習點滴(1)