java Spring MappeInterceptor映射语法
我试图在Spring中设置一些映射拦截器,但我找不到任何描述映射语法应该是什么的文档
考虑如下:
private MappedInterceptor[] createMappedInterceptor()
{
MappedInterceptor impersonationInterceptor = new MappedInterceptor(
new String[] {"*.do"}, new MyFirstInterceptor()
);
return new MappedInterceptor[]{
environmentInterceptor
};
}
从上面的示例中可以看出,其目的是将MyFirstInterceptor的一个实例映射到以“*.do”结尾的所有请求。但这不起作用,我的拦截器没有被引爆。这让我相信我的映射语法是错误的
Spring文档没有太多帮助:http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/servlet/handler/MappedInterceptor.html
有人知道映射语法应该是什么吗
# 1 楼答案
我做了一些调查,结果发现
"*.do"
是错误的语法。实际上需要的是"/*.do"
我测试的URL如下所示:
进行这种匹配的类是AntPathMatcher