怎样让上传附件在jsp页面上显示默认是下载
解决方案 »
- 如何用myeclipse8.6连接远程的oracle数据库
- 求助,不太懂,jsp调用servlet的方式
- Java如何打印条码?
- 用户很快的多次点击链接,在前一条sql没执行完就执行下一条,造成这个session假死,如何解决??感激!
- 在jsp中,是否有这样的函数:判断一个子串是否存在于一个串中?【100】
- 关于 JDBC 访问 My sql 数据库问题
- 有没有这样的开发模式,jsp+com,讨论一下吧
- 关于tomcat的配置问题,在线紧急等待!
- 如何判断输入的串是否全角文字?
- 求救!!!!!!!!!!!!!!
- 高手赐教:不继承Runable和Thread,struts中的action是怎样实现多线程的?
- JAVA中Result类功能是什么,不是ResultSet
var path=document.getElementById("fileName").value;
得到你附件里的文件的路径;
然后再对这个文件进行下载的操作,就可以了啊。
2.
3. response.reset();//可以加也可以不加
4. response.setContentType("application/x-download");//设置为下载application/x-download
5. // /../../退WEB-INF/classes两级到应用的根目录下去,注意Tomcat与WebLogic下面这一句得到的路径不同,WebLogic中路径最后没有/
6. ServletContext context = session.getServletContext();
7. String realContextPath = context.getRealPath("")+"\\plan\\计划数据模板.xls";
8. String filenamedisplay = "计划数据模板.xls";
9. filenamedisplay = URLEncoder.encode(filenamedisplay,"UTF-8");
10. response.addHeader("Content-Disposition","attachment;filename=" + filenamedisplay);
11.
12. OutputStream output = null;
13. FileInputStream fis = null;
14. try
15. {
16. output = response.getOutputStream();
17. fis = new FileInputStream(realContextPath);
18. byte[] b = new byte[1024];
19. int i = 0;
20.
21. while((i = fis.read(b)) > 0)
22. {
23. output.write(b, 0, i);
24. }
25. output.flush();
26. }
27. catch(Exception e)
28. {
29. System.out.println("Error!");
30. e.printStackTrace();
31. }
32. finally
33. {
34. if(fis != null)
35. {
36. fis.close();
37. fis = null;
38. }
39. if(output != null)
40. {
41. output.close();
42. output = null;
43. }
44. }
45. %>
response.addHeader("Content-Disposition","attachment; filename=JLFZ_ERR.xls"); //设置文件头难道你要意思是这个?
runescape gold
runescape power leveling
cheap runescape power leveling
rs powerleveling
runescape accounts
buy cheap runescape accounts
cheapest runescape accounts
rs accounts
runescape gold farming
runescape items
runescape gold
cheap runescape gold
buy runescape gold
runescape money
cheap runescape money
buy runescape money
runescape accounts
cheap runescape accounts
buy runescape accounts
runescape power leveling
runescape powerleveling
cheap runescape power leveling
runescape gold farming
runescape items
runescape gold
cheap runescape gold
buy runescape gold
runescape money
cheap runescape money
buy runescape money
runescape accounts
cheap runescape accounts
buy runescape accounts
runescape power leveling
runescape powerleveling
cheap runescape power leveling
runescape gold farming
runescape items
runescape gold
cheap runescape gold
buy runescape gold
runescape money
cheap runescape money
buy runescape money
runescape accounts
cheap runescape accounts
buy runescape accounts
runescape power leveling
runescape powerleveling
cheap runescape power leveling
runescape gold farming
runescape items