为 servlet 映射指定负路径匹配
有没有办法在 web.xml
中指定负映射?例如,我想为除匹配“/public/*
”之外的所有请求设置过滤器。
Is there a way to specify negative mappings in web.xml
? For example, I want to set a filter for ALL requests EXCEPT those matching '/public/*
'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,那不可能。您必须在
doFilter()
方法中自己进行 URL 模式匹配。将过滤器映射到/*
上并执行以下操作:或者当实际存在上下文路径时:
No, that's not possible. You'd have to do the URL pattern matching yourself inside the
doFilter()
method. Map the filter on/*
and do the following job:or when there's actually a context path: