Java

本类阅读TOP10

·使用MyEclipse开发Struts框架的Hello World!(录像1)
·hibernate配置笔记
·AOP编程入门--Java篇
·linux下Tomcat 5.0.20 与 Apache 2 安装/集成/配置
·在win2003下整合了整合Tomcat5.5+ apache_2.0.53+ mod_jk_2.0.47.dll
·构建Linux下IDE环境--Eclipse篇
·Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
·ASP、JSP、PHP 三种技术比较
·Tomcat5.5.9的安装配置
·AWT GUI 设计笔记(二)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
彻底解决Tomcat的页面提交时的中文问题

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

    <Connector port="8080"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000"
               disableUploadTimeout="true" URIEncoding="GBK"/>

就是在server.xml配置文件中加入 URIEncoding=“GBK”这句话。

现归纳一下Java中文问题,

1、页面中文显示,设置<meta http-equiv="content-type" content="text/html; charset=GBK">即可

2、Response用流向页面输出中文,要设置Response的字符集response.setCharaterEncoding(”GBK”)
      如果使用PrintWriter输出中文,只要设置<meta http-equiv="content-type" content="text/html; charset=gb2312">

3、提交中文,对于Tomcat就是使用开头的方法,对于Weblogic,可以使用一个Filter,在Filter里面,设置Request的字符集,request.setCharaterEncoding(”GBK”)

4、如果用的不是JSP做输出页面,而是Velocity,要在velocity.properties中设置
        velocimacro.library = webwork.vm, tigris-macros.vm
        input.encoding=GBK
        output.encoding=GBK
        default.contentType=text/html; charset=GBK

5、万能转换,String str = new String(”中文”.getBytes(”GBK”),”iso-8859-1”);
        上面的方法把GBK字符输出到iso-8859-1字符集的页面




相关文章

相关软件