前台ext调用方法 随便的一个方法名
this.MftDeclHeadAction + this.delcareReplenishManifest action 组成访问路径
action层
documentBuffer只是返回要下载的文件内容
onDeclare : function() {
window.open(this.MftDeclHeadAction + this.delcareReplenishManifest+"&manifestId="+this.mftDeclHeadForm.getForm().findField("manifestId").getValue());
}
this.MftDeclHeadAction + this.delcareReplenishManifest action 组成访问路径
action层
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("");
}
documentBuffer只是返回要下载的文件内容