有没有方法在(jsp,asp)中下一个文本文件

jk325 2003-04-25 01:08:51
在asp中以下语句可能行成一个excel文件download下来,

Response.ContentType = "application/vnd.ms-excel
有没有方法形成一个文本文件下过来。。。
急。。。。。。
...全文
42 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
moumouren 2003-04-25
  • 打赏
  • 举报
回复
不就是下载吗?

/*download.jsp*/

<%
try {

String url = "D:/aaaa.txt";//文件路径 可以用request.getParameter();取参数
String name = "aaaaaaaaaaaaaaaaaa";//显示给用户看的文件名,即ie弹出下载框中提示保存的文件名
response.reset();
response.setContentType("bin");
response.setHeader("Content-Disposition", "attachment; filename="+new String(name.getBytes(),"iso8859-1"));

ServletOutputStream os = response.getOutputStream();
FileInputStream in = new FileInputStream(url);
byte[] data = new byte[1024];
int temp = -1;
while((temp=in.read(data))!= -1){
os.write(data,0,temp);
os.flush();
}//while//

os.close();
} catch(Exception e) {
out.print(e.toString());
}
%>
blueeagle007 2003-04-25
  • 打赏
  • 举报
回复
把上一句的execl换成word试试?不过直接就保存文件了
sgdb 2003-04-25
  • 打赏
  • 举报
回复
好象走错地方了吧

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧