springmvc拦截器通过正则过滤静态资源

首先springmvc需要配置静态资源过滤,

其次在自定义过滤器中配置拦截的url,

url用正则设置即可

.*[^((js)|(png))]$代表的是不以js,png结尾的url,如果还有其他的只需要继续往中括号中添加(xx)即可

<mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
	<mvc:interceptors>
	<!--可以配置多个拦截器,按顺序执行  -->
	 <!--/**表示所有url包括url路径-->
		<mvc:interceptor>
			<mvc:mapping path=".*[^((js)|(png))]$" />
			<bean class="com.intercepter.LoginIntercepter" />
		</mvc:interceptor>
	</mvc:interceptors>

猜你喜欢

转载自blog.csdn.net/weixin_41796956/article/details/91948364