jsp页面如下:
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file = "/common/common.inc"%><%@
page import="java.io.*" %><%@
taglib uri="/WEB-INF/supp_struts.tld" prefix="supp" %><%@
include file = "/common/javascript.inc"%><%@
page import="com.supporter.prj.com_codetable.*"%><%@
page import="com.supporter.util.*" %><%@
page import="com.supporter.prj.file_upload.*" %>
<%
//接收参数
String fileName = request.getParameter("fileName");
if (CommonUtil.trim(fileName).length() <= 0) {
System.out.println("file_downlod.jsp: invalid fileId :" + fileName);
out.println("无效的文件标识:" + fileName);
return;
}
String ls_FilePath = pageContext.getServletContext().getRealPath("/").replace('\\','/') + "/bm/item/" + fileName;
FileInputStream lfis_Source = null;
OutputStream los_OutputStream = null;
try{
// response.setContentType("application/ms-excel");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition;charset=GBK", "attachment; filename=bbb" + CommonUtil.unicodeToGB(fileName));
response.setBufferSize(1024);
File lfile_F = new File(ls_FilePath);
lfis_Source = new FileInputStream(lfile_F);
los_OutputStream = response.getOutputStream();
byte[] larrbyte_Buffer = new byte[1024];
int li_Bytes = 0;
while((li_Bytes = lfis_Source.read(larrbyte_Buffer)) != -1){
los_OutputStream.write(larrbyte_Buffer,0,li_Bytes);
}
} catch (IOException e){
e.printStackTrace();
} finally {
if(lfis_Source != null){
lfis_Source.close();
}
if(los_OutputStream != null){
los_OutputStream.close();
}
}%>
xml配置了:
<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping>拜托各位高手帮解决一下,下载下来的文件乱码 (我用tomcat环境跑起来就不乱码,用weblogic跑起来就乱码)急~!!!!!!!!!!!!!!!!!!!!!!!
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file = "/common/common.inc"%><%@
page import="java.io.*" %><%@
taglib uri="/WEB-INF/supp_struts.tld" prefix="supp" %><%@
include file = "/common/javascript.inc"%><%@
page import="com.supporter.prj.com_codetable.*"%><%@
page import="com.supporter.util.*" %><%@
page import="com.supporter.prj.file_upload.*" %>
<%
//接收参数
String fileName = request.getParameter("fileName");
if (CommonUtil.trim(fileName).length() <= 0) {
System.out.println("file_downlod.jsp: invalid fileId :" + fileName);
out.println("无效的文件标识:" + fileName);
return;
}
String ls_FilePath = pageContext.getServletContext().getRealPath("/").replace('\\','/') + "/bm/item/" + fileName;
FileInputStream lfis_Source = null;
OutputStream los_OutputStream = null;
try{
// response.setContentType("application/ms-excel");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition;charset=GBK", "attachment; filename=bbb" + CommonUtil.unicodeToGB(fileName));
response.setBufferSize(1024);
File lfile_F = new File(ls_FilePath);
lfis_Source = new FileInputStream(lfile_F);
los_OutputStream = response.getOutputStream();
byte[] larrbyte_Buffer = new byte[1024];
int li_Bytes = 0;
while((li_Bytes = lfis_Source.read(larrbyte_Buffer)) != -1){
los_OutputStream.write(larrbyte_Buffer,0,li_Bytes);
}
} catch (IOException e){
e.printStackTrace();
} finally {
if(lfis_Source != null){
lfis_Source.close();
}
if(los_OutputStream != null){
los_OutputStream.close();
}
}%>
xml配置了:
<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping>拜托各位高手帮解决一下,下载下来的文件乱码 (我用tomcat环境跑起来就不乱码,用weblogic跑起来就乱码)急~!!!!!!!!!!!!!!!!!!!!!!!
解决方案 »
- 【散100分】溜达溜达看看我的'Z'代码··看看你的啦~!!
- 初始化 默认 最小化到侧边 怎没做,给讲讲原理
- struts2.0.x支持action注解吗?
- 请问 B/S结构java方面如何实现定时向数据库写入数据的工作?
- 进来帮帮忙 ,小弟感激不尽
- hibernate的.java文件怎么编译呀?
- 小弟!最近开始研究petstore,想从它的waf框架下手,不知道哪里有waf这方面的资料下载,请各位大虾指教!
- 用java 写了个applet 插入网页中 在状态栏中却提示 class not found 请各位大侠帮忙看看
- 给分100,关于JAVA环境配置问题
- struts总是配不成,烦死
- 有关国家对医辽信息系统建库表结构的标准规范
- 怎么样把double类型的字符串转化为整形
response.reset();//加上这句
// response.setContentType("application/ms-excel");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition;charset=GBK", "attachment; filename=bbb" + CommonUtil.uni..........
仅供参考