天天看點

Spring參考手冊 mvc:interceptors

This tag allows you to register custom HandlerInterceptors or WebRequestInterceptors that should be applied to all HandlerMapping beans.

You can also restrict the URL paths specifc interceptors apply to.

這個标簽注冊自定義的攔截器或請求攔截器

也可以攔截指定url路徑

An example of registering an interceptor applied to all URL paths:

注冊全部url到攔截器:

<mvc:interceptors>

<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />

</mvc:interceptors>

An example of registering an interceptor limited to a specific URL path:

注冊指定url到攔截器:

<mvc:interceptors>

<mvc:interceptor>

<mapping path="/secure/*"/>

<bean class="org.example.SecurityInterceptor" />

</mvc:interceptor>

</mvc:interceptors>

繼續閱讀