-
2005年12月20日
commons-fileupload中文乱码问题的解决
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
在广州地铁管理后台中使用了commons-fileupload来上传文件,发现中文路径或文件名都会变成乱码。但是上传部分的代码是已经在我们的QuickOA里面应用了的,而在QuickOA里面完全没有乱码问题。搜索fileupload的代码,发现在 FileUploadBase类里面有setHeaderEncoding方法,根据其说明,当读取上传表单的各部分时会用到该encoding,如果没有指定encoding则使用系统缺省的encoding。在QuickOA中因为页面是使用“GBK”编码,所以在简体中文的系统下面不会有乱码问题;而在广州地铁管理后台中页面是使用“UTF-8”编码,就必须指定编码。考虑到QuickOA以后有可能运行在英文或繁体中文之类的系统中,在 QuickOA中也指定编码。
http://fireshort.blogbus.com/logs/1727844.html
代码: /**
* Specifies the character encoding to be used when reading the headers of
* individual parts. When not specified, or <code>null</code>, the platform
* default encoding is used.
*
* @param encoding The encoding used to read part headers.
*/
public void setHeaderEncoding(String encoding)
{
headerEncoding = encoding;
}随机文章:
用Java进行LDAP编程的方式 2007年01月23日Java中对有BOM头的UTF-8文件的处理 2006年10月19日j2ee系统与rtx的整合实现 2006年07月27日javadbf中文问题的解决 2005年10月19日操作dbf的类库 2005年09月08日
收藏到:Del.icio.us
引用地址:





