diff options
author | Alexander Alexeev | 2016-12-11 20:24:36 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-12-11 18:24:38 +0300 |
commit | 87ce0ec2f1c293bebdf4a015703406359acaede5 (patch) | |
tree | 01f5e43768f36f5e39e28eb0c000e93623230e44 /juick-spring-www/src/main/java/com/juick | |
parent | 3a83f25cb30f34ef2c69c2ecdec372b83f04d8c5 (diff) |
Multipart resolver
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 2eb39e1c..8da3321e 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; + } } |