日期:2014-05-17  浏览次数:20871 次

下载文件在tomcat下正常,再weblogic下乱码,求助
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import= "java.net.URLEncoder"%>
<%@page import= "java.io.*"%>
<%@page import="java.io.OutputStream" %>
<%@page import="java.io.IOException" %>
<%try{
response.setHeader("Content-Type","application/force-download");
response.setHeader("Content-Type","application/vnd.ms-excel");
String fileName = "test.xls";

String fullFile = "C:\\"+fileName;
File file = new File(fullFile);
response.setHeader("Content-Disposition","attachment;filename=" + fileName);
int len = (int) file.length();
byte[] buf = new byte[len];
FileInputStream fis = new FileInputStream(file);
OutputStream out1 = response.getOutputStream();
int b = 0;
len = fis.read(buf);
out1.write(buf,b,len);
out1.flush();
out1.close();
fis.close();
//file.delete();
return;}catch(Exception ex){}%>

请各位帮忙看看,是不是要在什么地方设置weblogic编码?
直接打开test.xls文件正常,就是下载下来这个文件就乱码了,很奇怪


------解决方案--------------------
牛逼还没回答自己解决,自己动手丰衣足食