index.jsp中执行提交到servlet执行流格式下载如下:
String fileName = "1233.word";
File t_file = new File(downFilePath); FileInputStream fis = new FileInputStream(t_file);
ServletOutputStream fout = response.getOutputStream();
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-disposition", "attachment;filename=\"" + fileName + "\"");
int byteRead;
while ((byteRead = fis.read()) != -1) {
fout.write(byteRead);
}
fis.close();
fout.close(); response.sendRedirect("/index.jsp");发现最后句没用,请问有没什么其他方法?我想跳转回原来的页面
String fileName = "1233.word";
File t_file = new File(downFilePath); FileInputStream fis = new FileInputStream(t_file);
ServletOutputStream fout = response.getOutputStream();
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-disposition", "attachment;filename=\"" + fileName + "\"");
int byteRead;
while ((byteRead = fis.read()) != -1) {
fout.write(byteRead);
}
fis.close();
fout.close(); response.sendRedirect("/index.jsp");发现最后句没用,请问有没什么其他方法?我想跳转回原来的页面
response.sendRedirect(path);
试试
response.sendRedirect(path); -------
这个可以