Intercept the JSP page and verify whether it has been logged in. Explain and implement the code

Intercept the JSP page and verify whether it has been logged in

Recently, for projects using struts 2, it is necessary to intercept JSPS to verify whether they have been registered, but the filter chain of struts 2 can only filter actions. Later found on the web Javax. XML can be added directly servlet. Filter implements the filter of class, which can filter JSP. Look at the code

Filter implementation class

Login method:

web. XML configuration

Note that if a frame is used on the page, it may cause the session to time out and exit the login page. At this time, the login page is displayed on a sub page of the frame. The solution is to add the following code to the login page.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>