2

I am using Java8 with Spring 4.3.1.RELEASE.

I have the following folder structure.

I also have the following config:

@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //registry.addResourceHandler("*.html").addResourceLocations("/", "/www/");
        //registry.addResourceHandler("/html/**").addResourceLocations("/www/");
        registry.addResourceHandler("*.html").addResourceLocations("/");
    }
}

This allows me to access html files in the webapp folder.

e.g. http://localhost:8080/jbosswildfly-1.0/home.html

Question

How do I configure it, so that I can also access html files in the webapp/www folder?

e.g. http://localhost:8080/jbosswildfly-1.0/www/index.html

returns:

No mapping found for HTTP request with URI [/jbosswildfly-1.0/www/index.html] in DispatcherServlet with name 'rest'

Richard
  • 8,193
  • 28
  • 107
  • 228

1 Answers1

0

You may use The InternalResourceViewResolver to set the prefix and suffix part of the path. For example,

@Bean
public InternalResourceViewResolver getInternalResourceViewresolver(){
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setPrefix("/www/");
    viewResolver.setSuffix(".html");
    viewResolver.setOrder(0);
    return viewResolver;
}
Sebin Thomas
  • 279
  • 8
  • 21