首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

response.setContentType下载小疑点

2011-12-31 
response.setContentType下载小问题response.setContentType( application/msword )FileInputStreamfin

response.setContentType下载小问题
response.setContentType( "application/msword ");
FileInputStream   fin=new   FileInputStream(new   File(request.getRealPath( "/ ")+ "company "+File.separator+ "Hr_tool "+File.separator, "AAA.doc "));  
int   c=0;
while((c=fin.read())!=-1)
{
response.getOutputStream().write(c);
}
fin.close();

本人使用以上代码实现文件下载(下载AAA.doc文档),但是执行的时候,跳出文件另存为窗口,默认的文件名“JSP文件名.doc”,而不是“AAA.doc”,不知道如何设置另存为的默认文件名,请教了

[解决办法]
学习
[解决办法]
<%
response.setContentType( "application/ms-word ");
response.setHeader( "Content-disposition ", "inline; filename=AAA.xls ");//加上这句,应该可以了
%>

热点排行