79366372

Date: 2025-01-18 00:10:33
Score: 0.5
Natty:
Report link

I wanted to post my current working solution in case it helps anyone else, or so someone can tear it apart if I'm missing something. I was able to resolve with Spring MVC by defining an external resource handler and redirecting users to this:

@Configuration
public class CustomWebMvcConfigurer implements WebMvcConfigurer {
    @Value("${external.resource.location:file:///external/foo/}")
    private String externalLocation;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/foo/**")
                .addResourceLocations(externalResourcesLocation);
    }
}

After adding this configuration and placing my external file content in /external/foo/[index.html|js/|css], I'm now able to access my externalized content when navigating to localhost:<port>/foo/index.html without requiring it to be packaged or deployed within my .war file.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: billoot