improve configuration of the main Spring servlet
[proteocache.git] / server / compbio / spring / WebConfig.java
1 package compbio.spring;
2
3 import org.springframework.context.annotation.Bean;
4 import org.springframework.context.annotation.ComponentScan;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
8 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9 import org.springframework.web.servlet.view.InternalResourceViewResolver;
10
11 @Configuration
12 @EnableWebMvc
13 @ComponentScan(basePackages = "compbio.controllers")
14 public class WebConfig extends WebMvcConfigurerAdapter {
15
16         @Bean
17         public InternalResourceViewResolver viewResolver() {
18                 InternalResourceViewResolver resolver = new InternalResourceViewResolver();
19                 resolver.setPrefix("/WEB-INF/view/");
20                 resolver.setSuffix(".jsp");
21                 return resolver;
22         }
23
24         @Override
25         public void addResourceHandlers(ResourceHandlerRegistry registry) {
26                 registry.addResourceHandler("/bootstrap-3.0.2/**").addResourceLocations("/bootstrap-3.0.2/");
27                 registry.addResourceHandler("/css/**").addResourceLocations("/css/");
28                 registry.addResourceHandler("/images/**").addResourceLocations("/images/");
29                 registry.addResourceHandler("/js/**").addResourceLocations("/js/");
30         }
31
32 }