xml [spring mvc拦截器配置] #spring #java

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml [spring mvc拦截器配置] #spring #java相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<mvc:annotation-driven />

	<mvc:interceptors>
		<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/admin/**" />
			<mvc:exclude-mapping path="/images/**" />
			<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"/>
		</mvc:interceptor>
	</mvc:interceptors>

    <mvc:interceptors path-matcher="pathMatcher">
        <mvc:interceptor>
            <mvc:mapping path="/accounts/[0-9]*" />
            <bean class="org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor"/>
        </mvc:interceptor>
    </mvc:interceptors>

    <bean id="pathMatcher" class="org.springframework.web.servlet.config.MvcNamespaceTests$TestPathMatcher"/>

</beans>

以上是关于xml [spring mvc拦截器配置] #spring #java的主要内容,如果未能解决你的问题,请参考以下文章

Spring MVC Interceptor

spring拦截器

springMVC拦截器和过滤器总结

spring mvc 的dispatcherservlet是怎样拦截一切http请求的

Spring MVC关于静态资源的过滤(详解)(或者叫做拦截器)

Spring MVC关于静态资源的过滤(详解)(或者叫做拦截器)