* @throws Exception
*/
public ActionForward downloadFile(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
BaseActionForm aForm = (BaseActionForm) form;
Dto dto = aForm.getParamAsDto(request);
String fileid = dto.getAsString("fileid");
Dto fileDto = (BaseDto) g4Reader.queryForObject("Demo.queryFileByFileID", fileid);
// 这里可稍做优化,根据文件类型动态设置此属性
// response.setContentType("application/vnd.ms-excel");
String filename = G4Utils.encodeChineseDownloadFileName(request, fileDto.getAsString("title"));
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ";");
String path = fileDto.getAsString("path");
File file = new File(path);
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;