How can I set the priority of handler mappings in spring to allow resource handlers to map before controller request mappings?
For example this configuration:
@Configuration
@EnableWebMvc
@ComponentScan("org.commons.sandbox")
public class WebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
@Bean
public ViewResolver viewResolver(){
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setViewClass(JstlView.class);
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
}
With the following controller:
@Controller
public class HomeController {
@RequestMapping("/**")
public String home(){
return "home";
}
}
Captures requests to "/resources". So linking to a css file is the jsp returns the "home" view not the actual css file in the "resources" directory. I understand that it's due to the mapping "/**" but I would assume there's a way to configure the mapping order... is there?
Thanks!