package com.juick.www.configuration; import com.juick.configuration.DataConfiguration; import com.juick.configuration.SearchConfiguration; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; import javax.servlet.FilterRegistration; import javax.servlet.ServletContext; import javax.servlet.ServletException; /** * Created by aalexeev on 11/20/16. */ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class[] getRootConfigClasses() { return new Class[]{ WebAppConfiguration.class, DataConfiguration.class, SearchConfiguration.class, WebSecurityConfig.class}; } @Override protected Class[] getServletConfigClasses() { return new Class[]{WwwServletConfiguration.class}; } @Override protected String[] getServletMappings() { return new String[]{"/"}; } @Override protected String getServletName() { return "WWW-spring dispatcher servlet"; } @Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); FilterRegistration.Dynamic registration = servletContext.addFilter( "encodingFilter", new CharacterEncodingFilter("UTF-8", true)); registration.addMappingForUrlPatterns(null, true, "/*"); } }