I configured a specific folder (c:\data\cache\<html files>
) to be served statically by Spring Boot like this:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("cache/**")
.addResourceLocations("file:data/cache/");
}
These HTML files are being served well. The problem is the encoding. They're properly saved (as Windows-1252
- downloaded from a website). When I open them directly from disk in browser they're fine. But when Spring Boot serves them, it forces UTF-8
.
I saw a solution to change that - it works - but it changes the encoding to UTF-8
for every HTML:
@Override
public void customize(ConfigurableEmbeddedServletContainer factory) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
mappings.add("html", "text/html;charset=windows-1252");
factory.setMimeMappings(mappings);
}
But then my regular non-static pages gets served as Windows-1252
.
So I have to choose one or the other.
Is there any way to tell Spring to serve the static HTML "as is" (or manually specify the encoding)?
Thanks