📄 downloadaction.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 + -