java服务器下载文件浏览器无反应

用google浏览器作的测试
需求:
将指定内容以文件流的形式下载

代码:

@RequestMapping("saveSort")
public void saveSort(String[] id, HttpServletResponse response){
if (ArrayUtils.isNotEmpty(id)){
OutputStream out = null;
try {
String formatdata = tvSourceService.createConfigLine(id);
if (StringUtils.isBlank(formatdata)){
return ;
}
//下载
String fileName ="IPTV.txt";
response.reset();
response.setHeader("Content-Disposition","attachment; fileName="+URLEncoder.encode(fileName,"UTF-8"));
// response.setHeader("Cache-Control","max-age=0");
response.setContentType("multipart/form-data");
response.setCharacterEncoding("UTF-8");

out = response.getOutputStream();
out.write(formatdata.getBytes("UTF-8"));
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}


原因:
浏览器的下载插件影响(如迅雷)

解决:
方法1:停用浏览器下载插件
方法2:重置浏览器设置,见[url=http://jingyan.baidu.com/album/c33e3f48a1445fea15cbb537.html?picindex=1]百度经验[/url]

[img]http://dl2.iteye.com/upload/attachment/0118/2197/8bba3fe7-676b-3fce-80fb-16948570dd0f.png[/img]

你可能感兴趣的:(java)