Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package cz.muni.fi.pa165.rest.layer; import javax.servlet.Filter; import org.springframework.web.context.request.RequestContextListener; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.filter.ShallowEtagHeaderFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; public class Initializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class[] { RootWebContext.class }; } @Override protected Class<?>[] getServletConfigClasses() { return null; } @Override protected String[] getServletMappings() { return new String[] { "/" }; } @Override protected Filter[] getServletFilters() { CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter(); encodingFilter.setEncoding("utf-8"); encodingFilter.setForceEncoding(true); ShallowEtagHeaderFilter shallowEtagHeaderFilter = new ShallowEtagHeaderFilter(); return new Filter[] { encodingFilter, shallowEtagHeaderFilter }; } @Override public void onStartup(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException { super.onStartup(servletContext); servletContext.addListener(RequestContextListener.class); } }