Переход на Spring 4 MVC
This commit is contained in:
47
src/main/java/kinosearch/webapp/WebAppConfiguration.java
Normal file
47
src/main/java/kinosearch/webapp/WebAppConfiguration.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* DmitriyMX <mail@dmitriymx.ru>
|
||||
* 2017-01-04
|
||||
*/
|
||||
package kinosearch.webapp;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
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.freemarker.FreeMarkerConfigurer;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan
|
||||
public class WebAppConfiguration extends WebMvcConfigurerAdapter {
|
||||
@Bean
|
||||
public ViewResolver viewResolver() {
|
||||
FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
|
||||
viewResolver.setCache(true);
|
||||
viewResolver.setSuffix(".html");
|
||||
return viewResolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FreeMarkerConfigurer freemarkerConfig() {
|
||||
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
|
||||
freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/");
|
||||
return freeMarkerConfigurer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/css/**")
|
||||
.addResourceLocations("/css/");
|
||||
registry.addResourceHandler("/fonts/**")
|
||||
.addResourceLocations("/fonts/");
|
||||
registry.addResourceHandler("/js/**")
|
||||
.addResourceLocations("/js/");
|
||||
registry.addResourceHandler("/*.png")
|
||||
.addResourceLocations("/");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user