My application has a GET
mapping to all undefined paths.
@RestController
public class HelloController {
@GetMapping("/**")
public String hello() {
return "hello";
}
@GetMapping("/")
public String world() {
return "world";
}
}
In this case, the path /
resolves to world
, and all other paths resolve to hello
, this is because Spring resolves more specific patterns first.
However, this does not work with files in resources/static
like favicon.ico
, the path returns "hello"
. If the /**
path is not defined, then as expected, the favicon is returned. Spring seems to give the least preference to content in resources
.
I would like to understand this behavior and get around it.