Mvc:interceptors tag Configuration Interceptor in Spring3

Source: Internet
Author: User

mvc:interceptorsThis tag is used to register a custom interceptor or a webrequestinterceptors.

You can use the URL to define the path request interception, can achieve finer granularity interception control.

For example, in configuration file join

<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:mvc= "Http://www.springframework.org/schema/mvc"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/ Spring-beans-3.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/ Spring-mvc-3.0.xsd "><!--The following configuration will intercept all URL requests -<mvc:interceptors><Beanclass= "Org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /></mvc:interceptors><!--The following configuration will intercept the unique URL request -<mvc:interceptors><Mvc:interceptor><mvc:mappingPath= "/secure/*"/><Beanclass= "Org.example.SecurityInterceptor" /></Mvc:interceptor><Mvc:interceptor><mvc:mappingPath= "/admin/*.do"/><Beanclass= "Org.example.admin.ControlInterceptor" /></Mvc:interceptor></mvc:interceptors></Beans>

The interceptor defined only needs to be implemented

@Override

public boolean prehandle (HttpServletRequest req,httpservletresponse res, Object handler)

Mvc:interceptors tag Configuration Interceptor in Spring3

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.