From 8094d66534f47ed302d271da4dba1147fe6b2a3c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 6 Sep 2017 14:23:07 +0300 Subject: www: cleanup and fix configuration --- .../src/main/java/com/juick/www/configuration/WwwInitializer.java | 5 ++--- .../java/com/juick/www/configuration/WwwServletConfiguration.java | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'juick-www/src/main/java/com') diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java index d77bbdad..3a97c4be 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java @@ -19,7 +19,6 @@ package com.juick.www.configuration; import com.juick.configuration.DataConfiguration; import com.juick.configuration.SearchConfiguration; -import com.juick.server.configuration.BaseWebConfiguration; import org.apache.commons.codec.CharEncoding; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @@ -36,7 +35,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni @Override protected Class[] getRootConfigClasses() { return new Class[]{ - BaseWebConfiguration.class, + WwwServletConfiguration.class, WwwAppConfiguration.class, DataConfiguration.class, SearchConfiguration.class, @@ -47,7 +46,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni @Override protected Class[] getServletConfigClasses() { - return new Class[]{WwwServletConfiguration.class}; + return null; } @Override diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java index 7a5de28c..cad8cfdb 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java @@ -29,8 +29,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; +import org.springframework.core.Ordered; import org.springframework.http.CacheControl; import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.resource.PathResourceResolver; @@ -50,7 +52,7 @@ public class WwwServletConfiguration extends BaseWebConfiguration { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.setOrder(0); + registry.setOrder(Ordered.HIGHEST_PRECEDENCE); registry.addResourceHandler( "/scripts*.js*", "/style*.css*", @@ -65,6 +67,10 @@ public class WwwServletConfiguration extends BaseWebConfiguration { .addResourceLocations("/static/") .setCacheControl(CacheControl.maxAge(30, TimeUnit.DAYS).mustRevalidate().cachePublic()); } + @Override + public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { + configurer.enable(); + } @Inject private ServletContext servletContext; -- cgit v1.2.3