论坛首页 Web前端技术论坛

请教:从服务器端下载XML文件的jsp方法

浏览 4738 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-11-10  
  为什么我点击链接保存XML文件的时候,老是报使用下面的错?
  ”无法显示 XML 页。
使用 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。


--------------------------------------------------------------------------------

不支持从当前编码到指定编码的切换。处理资源 'http://132.229.64.150:9001/oms/query/task/BatchReceiptDownload.jsp?FileName=TaskSave200611101131569...

<?xml version="1.0"  encoding="UTF-8"?>“
  
  我检查了一下:路径和文件名都正确,我的下载文件的语句是:


  <%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*" %>
<%
  String path = com.ai.oms.web.OmsConst.ReceiptAbsolutePath;
  String fileName = request.getParameter("FileName");
  InputStream inStream=new FileInputStream( path + fileName);
  //设置输出的格式
  response.reset();
//  response.setContentType("application/ms-Word");
  response.setContentType("application/octet-stream");
  response.addHeader("Content-Disposition","inline; filename=" + fileName + "");

  //循环取出流中的数据
  byte[] b = new byte[100];
  int len;
  while((len=inStream.read(b)) >0)
  response.getOutputStream().write(b,0,len);
  inStream.close();
%>

论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics