简体   繁体   English

配置Tomcat 6以支持俄语cp1251编码

[英]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. 我正在将一个struts应用程序从Websphere迁移到Tomcat 6,我的应用程序支持俄语。 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. 在Websphere中我们使用传递JVM参数-Dclinet.encoding.override = cp1251,但是当我通过传递JVM参数-DFile.encoding = cp1251尝试使用tomcat时,系统不接受输入(我在搜索中的任何文本框)屏幕)并以无效输入响应。

I also tries passing the same parameter as of Websphere (-Dclinet.encoding.override=cp1251) but didnt solve my problem. 我也尝试传递与Websphere相同的参数(-Dclinet.encoding.override = cp1251),但没有解决我的问题。

You can use a servlet filter which sets the response encoding to workaround the problem. 您可以使用servlet过滤器设置响应编码以解决问题。 Check http://snippets.dzone.com/posts/show/5948 . 访问http://snippets.dzone.com/posts/show/5948 There is a sample code for the filter. 有一个过滤器的示例代码。 You need to replace the: response.setCharacterEncoding("UTF-8"); 您需要替换: response.setCharacterEncoding("UTF-8"); and request.setCharacterEncoding("UTF-8"); 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. 在此之后,您链接过滤器以获取所有请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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