首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

Struts1中文件上载

2012-07-03 
Struts1中文件下载Struts1中文件下载 2011年09月01日   网上复制一份代保存  public ActionForward execut

Struts1中文件下载

Struts1中文件下载
2011年09月01日
   网上复制一份代保存 
  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { FileDownLoadForm fdform =(FileDownLoadForm)form; String path = fdform.getFilePath(); response.setContentType("application/x-download"); String filenamedownload = path; String filenamedisplay = path.substring(path.lastIndexOf("/")+1); try { filenamedisplay = URLEncoder.encode(filenamedisplay,"UTF-8"); response.addHeader("Content-Disposition","attachme nt;filename=" + filenamedisplay); RequestDispatcher dispatcher = request.getRequestDispatcher(filenamedownload); if(dispatcher != null) { dispatcher.forward(request,response); } response.flushBuffer(); return null ; // return mapping.findForward("success"); }catch(FileNotFoundException e){ e.printStackTrace(); return mapping.findForward("error"); }catch(Exception e){ e.printStackTrace(); return null; } } 
  
  

热点排行