简体   繁体   中英

Tomcat UTF-8 encoding glitch

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).

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">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM