问题:frameset框架,在框架上一个页面有退出登陆的链接,现在点击这个链接能将session清空,但是跳转不是整个frameset跳到新页面,只是有退出登陆链接的那个页面跳转到了新页面.
解决:
protected void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String type = request.getParameter("type");
if(type != null && type.equals("logout")){
request.getSession().invalidate();
request.getRequestDispatcher("/logout.jsp").forward(request,response);
return;
}
}
logout.jsp
<%@ page
language="java"
contentType="text/html;charset=gb2312"%>
<%
out.println("<script>");
out.println("window.top.location.href='login.xhtml';");
out.println("</script>");
%>
退出登录链接的正确实现方式
本文详细介绍了如何在框架中实现退出登录功能,确保在点击退出登录链接时,只跳转到新页面而不影响整个框架。通过使用保护方法、会话失效与定向到特定页面的技巧,实现了登录状态的清理。
864

被折叠的 条评论
为什么被折叠?



