我用jsp文件生成以下列表
 aa.xls   打开     下载
 bb.xls   打开     下载
 cc.xls   打开     下载
 .....(略)现在有以下问题,当我点击打开时,显示全是乱码?请问这怎么解决?
此外,点下载我希望出现下载对话框那样下载,怎么做?
本人对此一点也不清楚,请各位指点一下!

解决方案 »

  1.   

    OutputStream output=null;
    HSSFWorkbook wb = new HSSFWorkbook();try {
    //fileName = new String(fileName.getBytes("iso8859-1"),"gb2312");
    response.setContentType("application/x-msdownload");
    response.setHeader("Content-disposition", "attachment; "
    + "filename="+ new String(fileName.getBytes("gb2312"),"iso8859-1"));

    output= response.getOutputStream();
    wb.write(output);
    output.flush();

    forward=null;
    } catch (Exception e) {
        e.printStackTrace();
        request.setAttribute("error", e.toString());
    forward = "error";
    } finally {
    if(output!=null){
    output.close();
    }
    }