由于上传文件的时候没有给文件重命名,
所以网站发表的文章中引用的图片很多都是中文名称的图片,
而这些图片在英文操作系统上就无法显示了。求各位指教下,这个问题该怎么解决?

解决方案 »

  1.   

    显示文件名字时做一下转码处理,new String(fileName.getBytes(),"ISO-8859-1") 当然也可以试试GBK什么的
      

  2.   

    问题解决了,只是不知道这个方法到底好不好?页面采用的是GBK编码的:
    <%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
    <META http-equiv="Content-Type" content="text/html; charset=GBK">我是这样解决问题的://FileInputStream fin = new FileInputStream(filepath);
    FileInputStream fin = null;
    try {
    fin = new FileInputStream(new String(filepath.getBytes("iso8859-1"), "GBK"));
    } catch (Exception e) {
    try {
    fin = new FileInputStream(new String(filepath.getBytes("iso8859-1"), "UTF-8"));
    } catch (Exception e1) {
    try{
    fin = new FileInputStream(filepath);
    }catch (Exception e2){
    }
    }
    }