你在后台设置一个,
<%
response.setContentType(fileminitype)
response.setHeader("Location",filename)
response.setHeader("Cache-Control", "max-age=" + cacheTime)
response.setHeader("Content-Disposition", "attachmentfilename=" + filename)//filename应该是编码后的(utf-8)
response.setContentLength(filelength)
OutputStream outputStream = response.getOutputStream()
InputStream inputStream = new FileInputStream(filepath)
byte[] buffer = new byte[1024]
int i = -1
while ((i = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, i)
}
outputStream.flush()
outputStream.close()
inputStream.close()
outputStream = null
%>
要重新设置contentType,如application/octet-stream,再加一个filenamefilename="XXXXX.txt"
response.setHeader("Content-Disposition", "attachmentfilename="+filename)
response.addHeader("Content-Disposition", "attachmentfilename="
+ new String(logname.getBytes("utf-8"), "ISO-8859-1"))
根据自己的变量名和编码 进行修改
Java是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。
Java是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)