I am running Spring Framework on GlassFish 4.0 and developing in NetBeans.
I have a web page with UTF-8 content:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
And just to be sure the form has also been set to UTF-8.
<form:form commandName="DocumentsCmd" acceptCharset="UTF-8">
I have an entry in a select
control containing Slovenian characters:
<option value="PC plačilne liste za zadnje 3 mesece">PC plačilne liste za zadnje 3 mesece</option>
This displays perfectly in the browser, however when I POST the form the String in Java comes through as:
PC plaÄilne liste za zadnje 3 mesece
So it seems that Glassfish and/or Spring are not interpreting the form as UTF-8.
After doing some research I've tried adding:
<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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
To web.xml, however that has made no difference.
What have I missed that will cause Spring/GlassFish to interpret the incoming POST request as UTF-8?
I just found this: CharacterEncodingFilter don't work together with Spring Security 3.2.0 which may be relevant as I do have this at the end of my web.xml:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
That question and answer are talking about Tomcat not GlassFish though...