我想让我的站点的最终用户从服务器下载文件,我尝试使用经典的方法,使用2个jsp文件:
index.jsp:
<a href="download.jsp">download the file</a>
download.jsp:
<%
String filename = "file.xls";
String filepath = "C:\\Files\\";
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
java.io.FileInputStream fileInputStream=new java.io.FileInputStream(filepath + filename);
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
%>但是,它不能在Fatwire 7.6.2中使用2页模板,这是因为我不允许在Fatwire中使用响应对象吗?
发布于 2014-11-30 08:18:02
在一个站点(也称为"fatwire") jsp中使用响应对象确实是不被鼓励的。使文件可在站点中下载的典型方法是在资产中对数据进行建模,然后使用blobserver标记来呈现url。有关示例和其他类似标签,请参阅http://docs.oracle.com/cd/E29542_01/apirefs.1111/e39371/JSP/render-getbloburl.html。
如果你不想把这些文件放到资源中,那么你最好不要使用blobserver标签,而只是让它们直接通过the服务器可用。
菲尔
https://stackoverflow.com/questions/23811448
复制相似问题