response妙用
1、弹框提示信息
response.getWriter().print("<script>alert('文件不存在或已删除!');</script>");
2、跨域下载附件
response.setStatus(302);
response.setHeader("location","http://11.1.249.6:8181/collect/filedown?id=1name=xx);
3、控制页面刷新
response.setHeader("refresh","1");
4、定时转入其他页面10秒后转入新的页面
response.setHeader("refresh", "10;URL=testResponse6.jsp");
5、附件下载
response.setContentType("image/jpeg");
response.setHeader("Content- Disposition","attachment;filename=Bluehills.jpg");
response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
6、设置无缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");