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

📄 downloadaction.java

📁 实现文件的上传下载
💻 JAVA
字号:
package com.inta.struts.action;

import java.io.File;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class DownloadAction extends org.apache.struts.actions.DownloadAction {

	protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		HttpSession session=request.getSession();
		String contentType=(String) session.getAttribute("contentType");
		String fileName=(String)session.getAttribute("fileName");
		
		response.setHeader("Content-disposition","attachment;fileName="+new String(fileName.getBytes("gbk"),("iso-8859-1")));
		File file=new File("d:\\"+fileName);
		return new FileStreamInfo(contentType,file);
		
	}

}

⌨️ 快捷键说明

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