Using regular expressions for filter-mapping

主宰稳场 提交于 2019-12-23 18:26:54

问题


I know I cannot use regular expressions for the url-pattern of a filter-mapping, but I wanted to know if it is possible somehow to map the filter using something like /foo/.+/*


回答1:


No. As to wildcard matching, the <url-pattern> only supports prefix (/folder/*) or suffix (*.extension) matching.

If you want more finer grained matching like as possible with Apache HTTPD's mod_rewrite, then use Tuckey's UrlRewriteFilter or OCPSoft Rewrite instead. They support mod_rewrite-like expressions by XML configuration.




回答2:


No. URL Patterns in Servlet does not support regular expressions. They can be only of these below three types:

  • Exact Pattern For Ex, /folder/abc.html, /folder/abc
  • Directory Pattern For Ex, /folder/abc/*
  • Extension Pattern For Ex, *.js, *.reports etc


来源:https://stackoverflow.com/questions/10886516/using-regular-expressions-for-filter-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!