开发者

Is there way to query "url-pattern" property from Java code of servlet filter?

开发者 https://www.devze.com 2023-04-12 17:13 出处:网络
Is there way to obtain \"url-pattern\" property from Java code of servlet filter ? I know I can pass same pattern in servlet init params but it se开发者_JAVA百科ems redundant.

Is there way to obtain "url-pattern" property from Java code of servlet filter ? I know I can pass same pattern in servlet init params but it se开发者_JAVA百科ems redundant.

Thanks!


In servlet 3.0 - yes:

public void init(FilterConfig cfg) {
   List<String> mappings = 
       cfg.getServletContext().getFilterRegistration(cfg.getFilterName())
          .getUrlPatternMappings();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消