1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <%@ page language="java" import="java.io.*,java.io.OutputStream,java.net.URLEncoder,javax.servlet.*" %>
- <%
- String FileName = request.getParameter("dakai");
- FileName = java.net.URLDecoder.decode(FileName, "UTF-8");//解决javaScript传参乱码
- System.out.println("文件名:"+FileName);
- //String name=this.getServletContext().getRealPath("")+"/HHH/Sunset.jpg";
- String name = "/home/appuser/nwyj/upload/"+FileName;
- //response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode(FileName,"GBK"));
- InputStream in = new FileInputStream(name);
- OutputStream Out = response.getOutputStream();
- try
- {
- int len = 0;
- byte[] buffer = new byte[1024];
- while((len = in.read(buffer,0,1024)) != -1)
- {
- Out.write(buffer,0,len);
- }
-
- out.clear();
- out = pageContext.pushBody();
- }
- finally
- {
- if(in != null)
- {
- try
- {
- in.close();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- %>
- </head>
- <body>
- </body>
- </html>
|