Recently, the function of Session timeout has not been implemented in the company's internal framework. Because of the iframe structure, when the Session timeout is clicked on the left system menu, the login box pops up again on the right side of iframe.
The problem is due to the absence of interceptors.
The idea of adding interceptor: When a user clicks menu after Session timeout, he needs to use Interceptor to intercept the preceding item, and judge whether user information still exists in the session at this time. If it does not exist, he should specify to log on to the main page.
The following code:
1) Firstly, the mvc:interceptor tag is added to the application Context-mvc.xml.
The above code first creates an interceptor named Session Timeout Interceptor in the system internal package and specifies the url allowed to access as a collection in the list.
When the user logs in from this address, there is no need to intercept.
Session Timeout Exception throw s the exception when the interception takes effect.
And go to blank.jsp page.
2) The second step is to create the interceptor Session Timeout Interceptor. The code is as follows:
Except for the permitted Url, any other Url will throw Session Timeout Exception to point to the landing page as long as it is not checked for the existence of Session. Session Timeout Exception does not need to write any operations.
3) Because the iframe layout will cause the landing box embedded problem, it can be implemented in the following way, the code is as follows:
Introduce a transit page transfer.jsp in blank.jsp. This page is used for post ing jumps and requesting login.do again.
top.location is specified to be displayed on the main page, not on the embedded page.
4) The fourth step requires a second login.do request, which is coded as follows:
When you enter the page, you automatically submit a login.do request, but previously, because the page allows login.do to enter, the operation can be judged in loginControl.
The code is as follows:
In the login method, this judgment is introduced to judge the second access to the information of the Control. If the user name is not available, it will automatically jump back to the login.jsp page and re-enter.
At this point, it has been successfully completed, if there are other links on the landing page, you can configure it in allowurl.
The above is reproduced from http://blog.csdn.net/fly2749/article/details/8702855.