0

I'm having trouble with special characters in my Tomcat projects. I have all of my files in UTF-8 with meta set for UTF-8 and still when I write łóęążźć in any form and send it by POST/GET method (I'm doing it by ajax with jQuery) I got something much more like: [|zB�D.

How can I fix it? I'm pretty sure it's because of Tomcat (I'm using 6.0 version).

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
Adrian Modliszewski
  • 1,114
  • 2
  • 18
  • 31
  • 1
    Possible duplicate: [Problems while submitting a UTF-8 form textarea with JQuery/AJAX](http://stackoverflow.com/questions/29751/problems-while-submitting-a-utf-8-form-textarea-with-jquery-ajax) – Kevin Ji May 29 '11 at 18:50
  • possible duplicate of [encoding problem in servlet](http://stackoverflow.com/questions/4296654/encoding-problem-in-servlet) and [Why does POST not honor charset](http://stackoverflow.com/questions/4392610/why-does-post-not-honor-charset-but-an-ajax-request-does-tomcat-6) – BalusC May 29 '11 at 18:59
  • Tomcat already have filter that sets character encoding to UTF-8 in conf/web.xml file. You should uncomment filter definition and fiter-mapping tags for `setCharacterEncodingFilter` – Pavel Repin Jul 29 '16 at 11:10

1 Answers1

6

Note that jquery's ajax() function will always transmit data with UTF-8 encoding.

In Tomcat, it's best to set the uRIEncoding option of the connector to UTF-8 (in server.xml). This is mainly for the encoding of the URLs but it seems to affect the encoding used with POST request (url encoded) as well:

<Connector
    port="8080"
    redirectPort="8443"
    uRIEncoding="UTF-8"
    maxThreads="100">
Codo
  • 75,595
  • 17
  • 168
  • 206