Reputation: 101
I have a spring boot application which is serving the AngularJS app within it. When I try to navigate using buttons, links etc everything is working good. But when try to refresh the page with F5, Spring container returns 404. Any clue about that? Below is Web configuration for the boot application.
@Configuration
public class UIWebConfig implements WebMvcConfigurer
{
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index.html");
registry.addViewController("/admin").setViewName("forward:/admin/index.html");
}
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
}
}
Upvotes: 0
Views: 52
Reputation: 364
Sorry, can't make comments so I have to post here :(
Could it be this line of code ??
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
I believe you're missing a '.' before the /static/ directory so the IDE knows you're ussing a relative (to your computer) directory.
Try it like this:
registry.addResourceHandler("/**").addResourceLocations("classpath:./static/");
Sorry if I'm wrong ! I'll delete it if so. Just trying to help :)
Upvotes: 1