All the source code in the project can be found in the linked repository ：https://github.com/chenhaoxiang/uifuture-ssm
First , Interceptors and filters are AOP The embodiment of the idea . Although the two functions are similar , But the actual technology is quite different .
Filters depend on Servlet There is , So you can't get away from Servlet Containers . Function based callback . Belong to Servlet Part of the norm （ It can only be applied to Web application ）. You can filter almost all requests , Examples of filters are in Servlet The container is called once during initialization . The purpose of using filters is to do some filtering operations , You can block changes request and response, In the request to pass in servlet perhaps Spring MVC Modify the global character encoding in front of the front controller , Filtering requests , complete CORS Cross domain requests, etc .