request mapping - Spring Boot: @RequestMapping Priority -


my spring boot application encountered problem follows:

i have 2 @requestmapping:

@requestmapping(value = "/{categoryslug:^[a-z0-9-]+$}/{slug:^[a-z0-9-]+$}") public modelandview atutorial(          @pathvariable(value = "categoryslug", required = false) string categoryslug,          @pathvariable(value = "slug") string slug) {      // (1) } 

and

@requestmapping(value = "/questions/**") public modelandview fix404() {      // (2) } 

i used (2) redirect 404 pages homepage.

but when go url like: https://w3stacks.com/questions/fix, want (2) requests processed in (1), /questions/fix coincides {categoryslug)/{slug}.

so how on (2), or in other words, can customize priority between @requestmapping or not?

thanks.

you can ignore questions word categoryslug of atutorial api. like;

@requestmapping(value = "/{categoryslug:^(?!questions)[a-z0-9-]+$}/{slug:^[a-z0-9-]+$}") 

with that, wouldn't call starts questions in atutorial api /questions/etc, ignore /questionscategory/etc

hence fix404 endpoint utilized have desired.


Comments