简体   繁体   中英

Configuring Tomcat 6 to support Russian cp1251 encoding

I am migrating a struts application from Websphere to Tomcat 6 and my application has support for Russian language. In Websphere we use to pass the JVM param -Dclinet.encoding.override=cp1251 but when I tried this with tomcat by passing the JVM argument -DFile.encoding=cp1251, the system doesnt accept input (I an any text box like in search screen) and responds with invalid input.

I also tries passing the same parameter as of Websphere (-Dclinet.encoding.override=cp1251) but didnt solve my problem.

You can use a servlet filter which sets the response encoding to workaround the problem. Check http://snippets.dzone.com/posts/show/5948 . There is a sample code for the filter. You need to replace the: response.setCharacterEncoding("UTF-8"); and request.setCharacterEncoding("UTF-8"); with the required encoding. Also you can modify the sample to load the encoding from the filter config. After this you chain the filter to get all the requests.

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