First working Spring-based version
[proteocache.git] / server / compbio / spring / WebConfig.java
diff --git a/server/compbio/spring/WebConfig.java b/server/compbio/spring/WebConfig.java
new file mode 100644 (file)
index 0000000..ba13b48
--- /dev/null
@@ -0,0 +1,33 @@
+package compbio.spring;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+@Configuration
+@EnableWebMvc
+@ComponentScan(basePackages = "compbio.controllers")
+public class WebConfig extends WebMvcConfigurerAdapter {
+
+       @Bean
+       public InternalResourceViewResolver viewResolver() {
+               InternalResourceViewResolver resolver = new InternalResourceViewResolver();
+               resolver.setPrefix("/WEB-INF/view/");
+               resolver.setSuffix(".jsp");
+               return resolver;
+       }
+
+       @Override
+       public void addResourceHandlers(ResourceHandlerRegistry registry) {
+               registry.addResourceHandler("classpath:/META-INF/resources/webjars/**").addResourceLocations("/webjars/");
+               registry.addResourceHandler("/bootstrap/**").addResourceLocations("/bootstrap/");
+               registry.addResourceHandler("/css/**").addResourceLocations("/css/");
+               registry.addResourceHandler("/images/**").addResourceLocations("/images/");
+               registry.addResourceHandler("/js/**").addResourceLocations("/js/");
+       }
+
+}
\ No newline at end of file