首页>代码>java servlet通过SmartUpload开发文件批量上传、批量下载源码分享>/fileBatchWithSmart/src/org/shengke/servlet/SmartDownloadServlet.java
package org.shengke.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;

/**
 * 文件单一下载
 */
public class SmartDownloadServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String filename = request.getParameter("filename");
		System.out.println("filename:"+filename);
		//单一文件下载没啥可说的
		SmartUpload su = new SmartUpload();
		su.initialize(getServletConfig(), request, response);
		//设置响应类型
		su.setContentDisposition(null);
		try {
			su.downloadFile("/images/"+ filename);
		} catch (SmartUploadException e) {
			e.printStackTrace();
		}
	}

}
最近下载更多
磊哥哥哥哥  LV13 2023年12月26日
a82338181  LV7 2021年9月2日
明123456  LV11 2021年5月27日
CC1999  LV14 2020年5月25日
li0426  LV3 2020年1月22日
liuyan1234  LV9 2019年5月27日
songlijun  LV13 2019年5月3日
pahirdin  LV12 2019年4月17日
f123654789  LV17 2018年12月16日
幸运疯子  LV13 2018年10月28日
最近浏览更多
磊哥哥哥哥  LV13 2023年12月26日
WBelong  LV7 2023年12月19日
uni-code_0123  LV1 2023年11月29日
jameshkj  LV8 2023年5月18日
ly4910  LV3 2023年2月21日
飘忽的茶树  LV9 2022年6月6日
bai620123  LV16 2022年4月16日
木易雨山  LV7 2021年11月2日
zql666  LV9 2021年9月28日
CoderMars  LV13 2021年9月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友