使用struts2-codebehind插件下载附件注解示例
使用struts2-codebehind-plugin-2.1.2.jar插件下载Excel附件注解示例
import org.apache.struts2.config.Result;import org.apache.struts2.config.Results;import org.apache.struts2.dispatcher.StreamResult;@Results({ @Result(name = FileDownloadAction.RESULT_EXCEL, value = "stream", type = StreamResult.class, params = { "contentType","application/vnd.ms-excel", "inputName", "stream","contentDisposition", "attachment;filename="file2.xls"","bufferSize", "1024" }) })public class FileDownloadAction { public static final String RESULT_EXCEL = "excel"; private InputStream stream; public String execute() throws Exception { stream = new FileInputStream("c:\\temp\\file.xls"); return RESULT_EXCEL; } //... getter and setter}