I have a spring boot project where i have included front end code as well in resources/static/ folder. I have set the context path as /ibo-modules and port as 9080. Now when i try to hit http://localhost:9080/ibo-modules/, spring boot will automatically load the index.html file from that. Now i want to change the url pattern for loading static files. For that, i tried two methods:
- Setting spring.mvc.static-path-pattern=/ui/**
- Created custom webMvcConfigurer as below
public class CustomWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/ui/**").addResourceLocations("classpath:/static/");
}
}
In both cases, whenever i hit http://localhost:9080/ibo-modules/ui/ it is not loading. I am getting 404 error. I had to explicitly enter http://localhost:9080/ibo-modules/ui/index.html to load the static page. But in my project, this is not intended. Can anyone help me resolve this issue?