Interceptors, filters, @Aspect differences

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.