add resource handler to be able to load htm/js
With the Angular update the smart people at google moved the location where the build output is written to. It is now in a subfolder called 'browser'. This means the default lookup locations of Spring don't work anymore.
This commit is contained in:
@@ -26,7 +26,7 @@ public class WebConfiguration implements WebMvcConfigurer, HardcodedValues, Prop
|
||||
|
||||
addResourceHandlerForPlottedImages(registry);
|
||||
|
||||
// addResourceHandlerForAngular(registry);
|
||||
addResourceHandlerForAngular(registry);
|
||||
}
|
||||
|
||||
private void addResourceHandlerForPlottedImages(final ResourceHandlerRegistry registry) {
|
||||
@@ -57,7 +57,7 @@ public class WebConfiguration implements WebMvcConfigurer, HardcodedValues, Prop
|
||||
// to determine which sub-page to show.
|
||||
//
|
||||
// This makes Angular also responsible for all 404 pages.
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/resources/").resourceChain(true)
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/resources/browser/").resourceChain(true)
|
||||
.addResolver(new PathResourceResolver() {
|
||||
@Override
|
||||
protected Resource getResource(final String resourcePath, final Resource location)
|
||||
@@ -65,7 +65,7 @@ public class WebConfiguration implements WebMvcConfigurer, HardcodedValues, Prop
|
||||
final Resource requestedResource = location.createRelative(resourcePath);
|
||||
|
||||
return requestedResource.exists() && requestedResource.isReadable() ? requestedResource
|
||||
: new ClassPathResource("/resources/index.html");
|
||||
: new ClassPathResource("/resources/browser/index.html");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user