title: How to modify static resource index.html in Spring Boot?
body: <p>I made a small webapp and I want to add credits note at the bottom of the index page. It would be easy to remove the note from the html page in the WAR file. So I thought I could modify resource 'index.html' this way:</p>
  
  <pre><code>public class MainPageTransformer implements ResourceTransformer {
      @Override
      public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException {
          String html = IOUtils.toString(resource.getInputStream(), UTF_8);
          html = html.replace("&lt;/body&gt;", "&lt;div style=\"position: absolute; bottom: 5px;\"&gt;Autor&lt;/div&gt;\n&lt;/body&gt;");
          return new ByteArrayResource(html.getBytes());
      }
  }
  </code></pre>
  
  <p>... and:</p>
  
  <pre><code>@Configuration
  public class WebMvcConfig extends WebMvcConfigurerAdapter {
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/client/index.html")
                  .addResourceLocations("classpath:/static/client")
                  .resourceChain(false)
                  .addTransformer(new MainPageTransformer());
      }
  }
  </code></pre>
  
  <p>After the MainPageTransformer.transform method is executed it throws exception:</p>
  
  <pre><code>java.io.FileNotFoundException: Byte array resource [resource loaded from byte array] cannot be resolved to absolute file path
  at org.springframework.core.io.AbstractResource.getFile(AbstractResource.java:114)
  at org.springframework.core.io.AbstractResource.getFileForLastModifiedCheck(AbstractResource.java:169)
  at org.springframework.core.io.AbstractResource.lastModified(AbstractResource.java:153)
  at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:240)
  at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
  at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
  </code></pre>
  
  <p>What do I do wrong? Is there a better way to achieve my goal? Thanks a lot!</p>