简体   繁体   中英

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

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 seems redundant.

Thanks!

In servlet 3.0 - yes:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM