/** * 初始化附件编辑页面 */ private void initOnlineEdit(HttpServletRequest request, HttpServletResponse response, AttachmentVO attachment, String uploadPath) throws ApplicationException { FileInputStream fileInputStream = null; BufferedInputStream bufferedInputStream = null; BufferedOutputStream bufferedOutputStream = null; try { // 获取输入输出流 fileInputStream = new FileInputStream(new File(uploadPath)); bufferedInputStream = new BufferedInputStream(fileInputStream); bufferedOutputStream = new BufferedOutputStream(response .getOutputStream()); response.setContentType("application/x-download"); response.setHeader("Content-disposition", "attachment; filename=" + attachment.getOverview()); byte[] buffer = new byte[1024]; int readBytes = 0; while ((readBytes = bufferedInputStream.read(buffer, 0, buffer.length)) != -1) { bufferedOutputStream.write(buffer, 0, readBytes); } bufferedOutputStream.flush(); } catch (IOException e) { throw new ApplicationException(e); } catch (Exception e) { throw new ApplicationException(e); } finally { try { fileInputStream.close(); bufferedInputStream.close(); bufferedOutputStream.close(); } catch (IOException e) { throw new ApplicationException(e); } } } /** * 编辑后上传处理 */ private int uploadAttachment(HttpServletRequest request, HttpServletResponse response, AttachmentVO attachment, String dir) throws ApplicationException { // 获取上传路径 String uploadPath = dir + File.separator + attachment.getImageUrl() + File.separator; try { PageContext pageContext = JspFactory.getDefaultFactory() .getPageContext(this.getServlet(), request, response, null, true, 8192, true); SmartUpload smartUpload = new SmartUpload(); smartUpload.initialize(pageContext); smartUpload.upload(); return smartUpload.save(uploadPath); } catch (ServletException e) { throw new ApplicationException(e); } catch (SmartUploadException e) { throw new ApplicationException(e); } catch (IOException e) { throw new ApplicationException(e); } } }
详细解决方案
WebOffice 开发文档-code
热度:567 发布时间:2012-10-24 14:15:58.0
相关解决方案
- weservice调用Server returned HTTP response code: 500 for URL解决方法
- 一个关于QR code(二维码) 的有关问题
- \nbproject\build-impl.xml:332: Preverification failed with error code 1. 异常
- JEECG(J2EE Code Generation) 基于代码生成器J2EE智能开发框架 公布新版本通知
- it.sauronsoftware.ftp4j.FTPException [code=550,message= /DLL:Permission denied,该怎么处理
- 急求:PL/SQL Developer 的Product code、Serial number以及Password,该怎么处理
- 请教两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对
- Server returned HTTP response code: 403 for URL如何解决
- code lover解决办法
- MyEclipse错误:Java was started but returned exit code = 1
- EF5 code first 实体继承的有关问题
- 求ef code first课程
- FCIAddFile(failed: code 一 [Failure opening file to be stored in cabinet]
- QR-Code[二维码生成],有这样的控件吗?解决办法
- FCIAddFile(failed: code 1 [Failure opening file to be stored in cabinet],该怎么解决
- VS设置这个是作什么用的? C++ -> code Generation -> Buffer Security check,该如何解决
- 请问个EF code first DbContext有关问题
- 顶者有分!Code First 共用数据库的有关问题
- csnd如何发图片!发代码如何让代码变色![code=C#][/code]如何用
- Code-First POCO有关问题
- 生手 求教,Weboffice 操作 Word 文档.呃.分不多,只有这几分了。
- CKFinder 加入验证之后,无法上传文件,出现HTTP Error: status code 302. I/O Error: Error #2038. 异常
- Event code: 3005 是咋回事呢
- EF Code First设置int主键初始值的有关问题
- asp.net entity framework code first用途?该如何解决
- asp.net entity framework code first 更新数据库?解决思路
- EF Code First,entity framework.数据表发生改变后如何避免
- 为什么总是出现“MSDTC 事务的导入失败: Result Code = 0x8004d00e。”错误
- [Serializable, ToolboxItem(true), DebuggerStepThrough, DesignerCategory("code")]解决方法
- Eval("code") 中的code应该写些什么东西啊解决方案