Write Filter

Implement javax.servlet.Filter interface

Implement the init, doFilter, and destroy methods
in the interface. In the init method, you can get some init-param parameters configured in web.xml.

Write interceptor logic in doFilter.

There is a catalina.jar in the lib under the Tomcat installation directory. After decompression, open the path:
org\apache\catalina\filters, you can see some filters implemented by Tomcat. These can be used as examples. Such as HttpHeaderSecurityFilter, the Filter can add some response headers, such as X-Frame-Options that prohibits the page from being displayed in the iframe. This Filter is only available in the higher version.

Guess you like

Origin blog.csdn.net/vxzhg/article/details/109742232