ba13b48d92e200a39b857076ad3ddf307a0dc2da
[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("classpath:/META-INF/resources/webjars/**").addResourceLocations("/webjars/");
27                 registry.addResourceHandler("/bootstrap/**").addResourceLocations("/bootstrap/");
28                 registry.addResourceHandler("/css/**").addResourceLocations("/css/");
29                 registry.addResourceHandler("/images/**").addResourceLocations("/images/");
30                 registry.addResourceHandler("/js/**").addResourceLocations("/js/");
31         }
32
33 }