jsp 保存excel 问题! 在页面的开始放上<%@ page contentType="application/vnd.ms-excel;charset=gb2312" %>替换掉<%@ page contentType="text/html; charset=GBK" %>就行了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先数据展现后点击按钮保存成excel文件怎样写代码 提示Internet 无法下载,请求站点不可用,找不到的错误信息 response.setContentType("application/octet-stream");response.addHeader("Content-Disposition", "attachment; filename=filename.xls");java.io.FileInputStream in = null;try{ in = new java.io.FileInputStream(“realpath” +"filename.xls"); byte[] buf = new byte[1024]; int l = 0; javax.servlet.ServletOutputStream sop = response.getOutputStream(); while ((l = in.read(buf, 0, 1024)) != -1) { sop.write(buf, 0, l); } sop.close(); in.close();}catch (Exception e){ e.printStackTrace();}试试就知道了,好用 搜索栏中的文字,怎样点击一下就没有了? 请问大家这个报错是怎么回事啊? 类中设置session的值,页面中无法取出,为什么? 急求一个关于checkbox的javascript oracle8 中如何使用外连结?急 求助,如何解密下面代码 由树型结构的表生成xml文件的问题! 请问那里有比较完整的JSP LOGIN代码 HELP!在TOMCAT中如何调用SERVLET?? 在servlet中有无jsp中类似“<jsp:setProperty name="a1" property="*" />” jsp页面问题(有开发经验的请进) JDK与tomcat开发JSP的入门问题,请指教!!!
后点击按钮保存成excel文件
怎样写代码
请求站点不可用,找不到的
错误信息
response.addHeader("Content-Disposition", "attachment; filename=filename.xls");
java.io.FileInputStream in = null;
try
{
in = new java.io.FileInputStream(“realpath” +"filename.xls");
byte[] buf = new byte[1024];
int l = 0; javax.servlet.ServletOutputStream sop = response.getOutputStream(); while ((l = in.read(buf, 0, 1024)) != -1)
{
sop.write(buf, 0, l);
}
sop.close();
in.close();
}
catch (Exception e)
{
e.printStackTrace();
}
试试就知道了,好用