I'm attempting to post a simple form that includes unicode characters to a servlet action. On Jetty, everything works without a snag. On a Tomcat server, utf-8 characters get mangled.
The simplest case I've got:
Form:
<form action="action" method="post">
<input type="text" name="data" value="It’s fine">`
</form>`
Action:
class MyAction extends ActionSupport {
public void setData(String data) {
// data is already mangled here in Tomcat
}
}
- I've got URIEncoding="UTF-8" on
<Connector>
in server.xml - The first filter on the action calls request.setCharacterEncoding("UTF-8");
- The content type of the page that contains the form is "text/html; charset=UTF-8"
- Adding "accept-charset" to the form makes no difference
The only two ways I can make it work are to use Jetty or to switch it to method="get". Both of those cause the characters to come through without a problem.