aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/configuration/ApiMvcConfiguration.java4
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java17
2 files changed, 19 insertions, 2 deletions
diff --git a/juick-api/src/main/java/com/juick/api/configuration/ApiMvcConfiguration.java b/juick-api/src/main/java/com/juick/api/configuration/ApiMvcConfiguration.java
index 5a953c1f..37c07434 100644
--- a/juick-api/src/main/java/com/juick/api/configuration/ApiMvcConfiguration.java
+++ b/juick-api/src/main/java/com/juick/api/configuration/ApiMvcConfiguration.java
@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Configuration;
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.WebMvcConfigurationSupport;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@@ -40,8 +41,9 @@ public class ApiMvcConfiguration extends WebMvcConfigurationSupport {
converters.add(converter);
super.configureMessageConverters(converters);
}
+
@Bean
- public CommonsMultipartResolver multipartResolver() {
+ public MultipartResolver multipartResolver() {
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(10000000);
return resolver;
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;
+ }
}