Spring MVC Interceptor

Source: Internet
Author: User

Interceptors are for mapping. The corresponding interception can be configured under mapping. Because of the common Mvc:annotation-driven configuration mapping and adapter, the interceptor is configured here with Mvc:interceptors.

1, a single mapping interceptor A, the definition of interceptors. The

implements the Interceptor interface.

 

 

 

 

B, configure interceptor

 

 

Intercept Queryuser.action, a specific (queryuser.action)

 

C, controller

 

 

 

 

d, test, console displays

 

 

 

2, multiple interceptors

is performed in the configuration order.

A, increase interceptor

 

 

B, configuration

1 before, 2 after

 

 

 

C, console

 

 

Prehandle executes Posthandle and aftercompletion in the order of the Interceptor in reverse order.

 

D, Analog interceptors are not released. Will interceptor 2, set not released.

  test results.

 

Interceptor 2 interception, Interceptor 2 methods Posthandle and aftercompletion are not executed, Interceptor 1, performed aftercompletion.

As long as an interceptor is not released, the Posthandle will not be released.

 

 

Two interceptors are not released.

 

 

The

performs only 1 of the prehandle.

 

3, similar to the global interceptor.

Focus: Note the configuration path and the order in which the interceptors are understood.

 

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.