📄 servletdownload.java
字号:
package com.upload.ajax;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jspsmart.upload.SmartUpload;
public class ServletDownload extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String temp_p = request.getParameter("downloadFileName");
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String fileName = new String(temp_t,"GBK");
SmartUpload mySmartUpload = new SmartUpload();
try{
mySmartUpload.initialize(config,request,response);
mySmartUpload.setContentDisposition(null);
mySmartUpload.downloadFile("/upload/"+fileName);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(arg0,arg1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -