Accessing a static html page from a jar file using spring

I want to call the home.html file present in the jar under / WEB-INF / lib using spring.

Below is the config class

@Configuration
@ComponentScan("com.barclays.mobile.gateway.controller")
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter{

@Bean(name = "viewResolver")
public InternalResourceViewResolver getViewResolver() {
    InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
    viewResolver.setPrefix("/WEB-INF/");
    viewResolver.setSuffix(".html");
    return viewResolver;
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/component/**").addResourceLocations("classpath:/app/component/*");
   registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/app/assets/*");
   registry.addResourceHandler("/home/**").addResourceLocations("classpath:/app/*");
}

}

      

Below is the controller:

@Controller
public class StaffController {

@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home() {
    return "home";
}
}

      

Please suggest how to do this.

+3


source to share


1 answer


remove /

from /home

i think this is the problem



0


source







All Articles