vendredi 6 mars 2015

Spring resource file as root

I have a single-page webapp with a spring java-config setup. Currently, I have to enter localhost/resources/index.html to get to my app. I would like to set it up so I can just enter localhost and then see the index.html page.


This is my WebConfig. I don't know if this is where I need to be messing with stuff but I tried adding registry.addResourceHandler("/").addResourceLocations("resources/index.html") but that didn't work. Any ideas? Am I going about this the wrong way?



@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.example.web")
public class WebConfiguration extends WebMvcConfigurerAdapter
{

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/resources/**").addResourceLocations("resources/").setCachePeriod(31556926);
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}

...
}

Aucun commentaire:

Enregistrer un commentaire