When the session expires, you can use a filter to set the redirection page.
| The code is as follows: |
Copy code |
Public class ActionFilter extends HttpServlet implements Filter { Private FilterConfig filterConfig; Public void init (FilterConfig config ){ This. filterConfig = config; } Public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) servletRequest; ServletRequest. setCharacterEncoding ("UTF-8 & Prime ;); HttpServletResponse res = (HttpServletResponse) servletResponse; String url = req. getRequestURI (); SysUserVOImpl user = (SysUserVOImpl) req. getSession (). getAttribute ("SysUser "); If (null = user ){ If (! COMMON. isEmpty (url) & (url. endsWith ("newestlogin. jsp ") | url. endsWith ("UserLoginAction. jsp ") | url. endsWith ("login. jsp ") | url. endsWith ("loginAction. do "))){ FilterChain. doFilter (servletRequest, servletResponse ); } Else { Req. getRequestDispatcher ("/newestlogin. jsp"). forward (req, res ); } } Else { FilterChain. doFilter (servletRequest, servletResponse ); } } |
However, you cannot jump out of frameworks such as iframe.
It can be solved using javaScript
Add the following code between the pages you want to control the redirection, such as
| The code is as follows: |
Copy code |
<Script language = "JavaScript"> If (window! = Top) Top. location. href = location. href; </Script> |
JS refresh framework script statement
| The code is as follows: |
Copy code |
// How to refresh the page containing the framework <Script language = JavaScript> Parent. location. reload (); </Script> // Refresh the parent window in the child window <Script language = JavaScript> Self. opener. location. reload (); </Script> (Or <a href = "javascript: opener. location. reload ()"> refresh </a>) // How to refresh the page of another framework <Script language = JavaScript> Parent. Another FrameID. location. reload (); </Script> If you want to refresh the window when closing the window or refresh the window when opening the window, you can call the following statement in <body>. <Body onload = "opener. location. reload ()"> refresh when opening a window <Body onUnload = "opener. location. reload ()"> refresh when disabled <Script language = "javascript"> Zookeeper opener.doc ument. location. reload () </Script> |