diff options
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick')
-rw-r--r-- | juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java index 2eb39e1c2..8da3321e1 100644 --- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java +++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java @@ -9,9 +9,12 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.format.FormatterRegistry; +import org.springframework.http.CacheControl; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.multipart.MultipartResolver; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; @@ -23,6 +26,7 @@ import org.thymeleaf.spring4.view.ThymeleafViewResolver; import org.thymeleaf.templatemode.TemplateMode; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Created by vitalyster on 28.06.2016. @@ -102,9 +106,13 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport { "/*.png", "/favicon.ico") .addResourceLocations("/") + .setCacheControl(CacheControl.maxAge(30, TimeUnit.DAYS)) .resourceChain(true) .addResolver(new PathResourceResolver()); - registry.addResourceHandler("/static/**").addResourceLocations("/static/"); + + registry.addResourceHandler("/static/**") + .addResourceLocations("/static/") + .setCacheControl(CacheControl.maxAge(30, TimeUnit.DAYS)); } @Override @@ -125,4 +133,11 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport { public SpringDateFormatter dateFormatter() { return new SpringDateFormatter(); } + + @Bean + public MultipartResolver multipartResolver() { + CommonsMultipartResolver resolver = new CommonsMultipartResolver(); + resolver.setMaxUploadSize(10000000); + return resolver; + } } |