⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downfileaction.java

📁 实现一个J2EE上传功能完整的源代码
💻 JAVA
字号:
package com.action;import java.io.File;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.actions.DownloadAction;import org.apache.struts.actions.DownloadAction.FileStreamInfo;import org.apache.struts.actions.DownloadAction.StreamInfo;public class DownFileAction extends DownloadAction {	protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,			HttpServletRequest request, HttpServletResponse response)			throws Exception {		String fileid = request.getParameter("fileid");		String filename = request.getParameter("filename");		String filetype = request.getParameter("filetype");		String endname = filename.substring(filename.indexOf("."));		String downname = fileid + endname;		String dirpath = servlet.getServletContext().getRealPath("/file");		File file = new File(dirpath, downname);		FileStreamInfo fsi = new FileStreamInfo(filetype, file);		response.setHeader("Content-disposition", "attachment;filename="				+ downname);		return fsi;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -