1. What is an interceptor
Interceptors are enhancements to the functionality of a request that is sent to the server by a unified intercept from the browser
The client browser requests data from the server, which returns the corresponding data to the client, making changes to the request and return data during the request and return process, or adding some code to modify the data before and after the request.
2. Usage Scenarios
Solve some common problems of the request: garbled problem, permission verification problem, etc.
3. How the Interceptor Works
SPRINGMVC can be configured by the filter to solve the garbled problem, we do not need to write code in each file to do something, only need to configure the appropriate filter in Web. XML, and set the Url-pattern property, you can set which files need to be filtered.
Interceptors and filters are very similar in principle
3. Implementation of interceptors
1) write an interceptor class to implement the Handlerintercepter interface
2) Register the interceptor in the SPRINGMVC frame
3) Configure interception rules for interceptors
<mvc:mapping path= "/login.form" > indicates which request to intercept. The value in path is set according to the request that needs to be intercepted.
Spring MVC Interceptor