-1

I have this URL matching

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

All URLs like:

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

Should return index.html. It works but I need to skip static resources. And I don't know how to do it. Something like this:

"/portal/{not word static}/*" - in other words, this URL should be not handled: /portal/static/css/main.css

Pavel Petrashov
  • 1,073
  • 1
  • 15
  • 34
  • You can use something like this: `/portal/(?!static).*`, see also: [Regex not operator](https://stackoverflow.com/questions/7317043/regex-not-operator) – Lino Mar 29 '21 at 15:32
  • 1
    Also note that `get("/portal/*", ..)` is probably not a regex, so you'd need to find a way to configure the path match to use regex – Lino Mar 29 '21 at 15:36
  • 1
    Assuming you're using Spark Framework, the `get` method doesn't use regular expressions. You are asking the wrong question. – k314159 Mar 29 '21 at 15:43
  • @k314159 I agree. If you know this framework, could you help me with another question? https://stackoverflow.com/questions/66851385/how-can-i-return-index-html-from-webapp-folder-instead-of-resources-folder-in – Pavel Petrashov Mar 29 '21 at 15:52

1 Answers1

0

You could try this:

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

You can try it on regex101.

lnogueir
  • 1,859
  • 2
  • 10
  • 21