I have requirement to handle all request except few with single handler method in spring boot.
The valid urls that should be serveed -
/test/login
/test/dashboard
/test/validate/details
and the invalid urls that should not be served is -
/test/asset/login
/test/asset
/test/validate/asset
basically any URL which contains string "asset" should not be handled.
So far I am trying it as follows but it's not working -
@GetMapping("test/{path:^(?!.*(asset))}")
String hello(String path){
return "hello>>" + path;
}
But this is not working. I think there is some problem with the regex that I am using.
Any help is much appreciated.
Try this regex:
^(?:(?!asset).)*$