1, the requirements of the scene before also in the article wrote "Interceptor \ Filter" The difference, the article link, in the actual development process, we may encounter the requirements of the interception request parameters, in this I give a scene.
The request parameters of an interface are encrypted, and there are some business-independent data in the request parameter that need to be removed.
2, the problem arises
So how can you achieve as long as the business-related data?
First of all, we think of the use of the interceptor to decrypt the encrypted data, and then put the decrypted data back into the request, Request.setattribute ("Data name", data); In fact, it is possible to intercept the data in the method by @before, @around and @after annotations through @Aspect annotations, which is simpler to configure than the Interceptor.
Doubts are created in this way, what is the difference between a interceptor and a @Aspect annotation?
3, the question summary 3.1, three different @Aspect annotation form is one kind of AOP realization. The main use of AOP is dynamic proxies. The main use of the filter is reflection. The main use of interceptors is callbacks. 3.2, example analysis of a request from the foreground, the filter will be processed first to see if the program accepts the request. After the filter is placed, the interceptor in the program is processed and then processed into the main business class that is recompiled by the AOP dynamic agent. Through the example to understand the three differences, so there is no relationship between the three. Blog Address: Https://www.cnblogs.com/niceyoo
Interceptors, filters, @Aspect differences