title: Spring Boot application cannot access images via extra context path
body: <p>I have a spring boot application and in that I am using embedded tomcat and for accessing some image I have stored them at one location and adding that location to context path dynamically but it is showing 404 error:</p>
  <p>Here is my code as below:</p>
  <pre><code>@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class, FreeMarkerAutoConfiguration.class})
  public class AddonApplication extends SpringBootServletInitializer {
  
  public static void main(String[] args) throws Exception {
      new SpringApplication(AddonApplication.class).run(args);
  }
  
  
  @Bean
  public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
      return new TomcatServletWebServerFactory() {
          @Override
          protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) {
              tomcat.enableNaming();
              try {
                  tomcat.addContext(&quot;/locimages/**&quot;, &quot;/opt/locaimages&quot;);
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              return super.getTomcatWebServer(tomcat);
          }
  
      };
  }
  
  }
  </code></pre>
  <p>and my controller is as below:</p>
  <pre><code>@Controller
  public class Html5PathsController {
  
      @RequestMapping(value = &quot;/**/{path:[^\\.]*}&quot;)
      public String forward() {
          return &quot;forward:/index.html&quot;;
      }
  }
  </code></pre>
  <p>and while accessing images it is showing:</p>
  <pre><code>http://localhost:8569/locaimages/1.png  and it shows 404 Error
  </code></pre>
  <p>application.yml file:</p>
  <pre><code>server.servlet.context-path: /
  </code></pre>
  <p>Please let me know if I am missing anything.</p>