/*
 * The MIT License
 *
 * Copyright 2015 Ivar Grimstad (ivar.grimstad@gmail.com).
 * Copyright 2015 Rene Gielen (rene.gielen@gmail.com).
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package net.rgielen.actionframeworks.springmvc;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @author Rene Gielen
 */
public class ApplicationInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(ApplicationConfig.class);
        servletContext.addListener(new ContextLoaderListener(context));

        ServletRegistration.Dynamic registration =
                servletContext.addServlet("dispatcher", new DispatcherServlet(context));
        registration.setLoadOnStartup(1);
        registration.addMapping("/");

    }

}

@@ -1501,73 +1501,99 @@
 web.
-servlet.DispatcherServlet
+filter.CharacterEncodingFilter
 ;%0A
-%0A
 import 
-javax.servlet.ServletContex
+org.springframework.web.servlet.DispatcherServle
 t;%0A
+%0A
 impo
@@ -1613,66 +1613,35 @@
 let.
-ServletException;%0Aimport javax.servlet.ServletRegistration
+*;%0Aimport java.util.EnumSet
 ;%0A%0A/
@@ -2064,24 +2064,545 @@
 context));%0A%0A
+        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();%0A        characterEncodingFilter.setEncoding(%22UTF-8%22);%0A        characterEncodingFilter.setForceEncoding(true);%0A%0A        EnumSet%3CDispatcherType%3E dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);%0A%0A        FilterRegistration.Dynamic characterEncoding = servletContext.addFilter(%22characterEncoding%22, characterEncodingFilter);%0A        characterEncoding.addMappingForUrlPatterns(dispatcherTypes, false, %22/*%22);%0A%0A
         Serv

add UTF-8 encoding filter