繁体   English   中英

匹配除带有“静态”字词的 url 之外的所有 url

[英]match all urls except urls with “static” word

我有这个 URL 匹配

get("/portal/*", (req, res) -> { Map<String, Object> model = new HashMap<>();
                return new VelocityTemplateEngine().render(
                        new ModelAndView(model, "../../portal/index.html")
                );
            });

所有网址如:

/portal/
/portal/orders
/portal/orders/123
/portal/foo/bar

应该返回 index.html。 它有效,但我需要跳过 static 资源。 而且我不知道该怎么做。 像这样的东西:

“/portal/{not word static}/*” - 换句话说,这个 URL 不应该被处理: /portal/static/css/main.css

你可以试试这个:

\/portal\/(?!static\/).*

你可以在regex101上试试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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