简单文件下载
前台ext调用方法 随便的一个方法名
onDeclare : function() {window.open(this.MftDeclHeadAction + this.delcareReplenishManifest+"&manifestId="+this.mftDeclHeadForm.getForm().findField("manifestId").getValue());}public ActionForward sendReplenishDoc(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception {if (request.getParameter("manifestId") != null) {String mftId = (String)request.getParameter("manifestId"); try { StringBuffer documentBuffer = this.mftDeclManager.getReplenishDoc(mftId);response.setContentType("application/x-download"); response.setHeader("content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(mftId+".xml", "UTF-8"));byte[] bytes = documentBuffer.toString().getBytes("UTF-8"); BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(bytes)); OutputStream out = new BufferedOutputStream(response.getOutputStream()); int i=-1;while ((i = bis.read()) != -1) {out.write(i);}out.close();bis.close();}catch(Exception e){e.printStackTrace();}}return mapping.findForward("");}