Basic Webapp Internationalization

David Winterfeldt

2008


Creating a basic webapp that will handle UTF-8 characters from form input and also have internationalized messages.

1. Web Configuration

The character encoding type for the request can be set using the CharacterEncodingFilter. By setting this, when a form values are retrieved from the request the encoding type will be UTF-8.

/WEB-INF/web.xml
                
<filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>
        org.springframework.web.filter.CharacterEncodingFilter
    </filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>