/**
* 初始化附件编辑页面
*/
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
相关解决方案
- \nbproject\build-impl.xml:332: Preverification failed with error code 1. 异常
- it.sauronsoftware.ftp4j.FTPException [code=550,message= /DLL:Permission denied,该怎么处理
- MyEclipse错误:Java was started but returned exit code = 1
- EF5 code first 实体继承的有关问题
- 求ef code first课程
- VS设置这个是作什么用的? C++ -> code Generation -> Buffer Security check,该如何解决
- 请问个EF code first DbContext有关问题
- csnd如何发图片!发代码如何让代码变色![code=C#][/code]如何用
- Code-First POCO有关问题
- 生手 求教,Weboffice 操作 Word 文档.呃.分不多,只有这几分了。
- EF Code First设置int主键初始值的有关问题
- asp.net entity framework code first 更新数据库?解决思路
- 为什么总是出现“MSDTC 事务的导入失败: Result Code = 0x8004d00e。”错误
- Eval("code") 中的code应该写些什么东西啊解决方案
<?xmlversion="1.0"encoding="utf-8" ?>
- assume cs:code,ds:date,ss:strack,该如何解决
- |C$$code| 在arm起步代码里是什么
- 这个输出的为乱码,要求输出为如:THE ASCII CODE OF 10 IS A,该如何解决
- ,关于t-code:sgen的有关问题!
- SQLFetch failed: {error} STATE=22002, CODE=零, MSG=[DataDirect][ODBC Informix dri
- SQLFetch failed: {error} STATE=22002, CODE=0, MSG=[DataDirect][ODBC Informix dri解决方案
- Operation not allowed for reason code "3" on table xxx,该如何处理
- Operation not allowed for reason code "3" on table xxx,该怎么处理
- SQL state [null]; error code [-99999]; [ibm][db2][jcc][10120][10898] 操作无效:已关闭
- ColdFusion查询:ODBC Error Code = 22001 (String data right truncation),该怎么处理
- ODBC Error Code = S1000 [MySQL][ODBC 3.51 Driver]解决方案
- ColdFusion查询:ODBC Error Code = 22001 (String data right truncation)解决办法
- java/lang/OutOfMemoryError:Maximum byte code length (32kB) exceeded
- O'Reilly新书《编纂可读代码的艺术》(The Art of Readable Code)
- AIX中出现的Segmentation fault(code dump)怎么解决