Spring MVC Interceptor

Source: Internet
Author: User

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

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.