dsoframer-在线编辑(读取保存服务器文档)
来源:互联网 发布:三星note8网络参数 编辑:程序博客网 时间:2024/05/14 10:18
jsp代码:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ include file="/pages/common/getPath.jsp" %><%@ page import="com.daorigin.common.dto.SessionDto" %><%SessionDto sessionDto=(SessionDto) request.getSession().getAttribute("sessionDto");String filePath = request.getParameter("filePath");String fileType = request.getParameter("fileType");%><!DOCTYPE html><html lang="zh-CN"><head><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><link rel="stylesheet" type="text/css" href="<%=path%>/public/css/smelp.css"> <link type="text/css" rel="stylesheet" href="<%=path%>/public/bootstrap32/css/bootstrap.min.css" /><link type="text/css" rel="stylesheet" href="<%=path%>/public/temp/font-awesome.min.css" /> <link type="text/css" rel="stylesheet" href="<%=path%>/public/temp/main2.css" /><script type="text/javascript" src="<%=path%>/public/js/officeOnline.js"></script><script type="text/javascript" src="<%=path%>/public/js/jquery-1.9.1.min.js"></script> <script type="text/javascript"> $(function(){ var height = window.innerHeight-47; $("#oframe").attr("height",height+"px"); }) function openWord(){ var filePath = '<%=filePath%>'; var webUrl = "<%=basePath%>/common/file/getWord.do?filePath="+filePath; OpenWebWord(webUrl); ToggleMenubar(); ToggleRibbonBar(); ToggleMenubar(); ToggleShowRevisions(true); SetUserName('<%=sessionDto.getUserName()%>'); } function saveToWeb(){ var filePath = '<%=filePath%>'; document.getElementById("oframe").HttpInit(); document.getElementById('oframe').HttpAddPostString("filePath",filePath); document.getElementById("oframe").HttpAddPostCurrFile("FileData",""); document.getElementById("oframe").HttpPost("<%=basePath%>/common/file/saveToWeb.do"); alert("保存成功!"); } function isIE() { //ie? if (!!window.ActiveXObject || "ActiveXObject" in window) return true; else return false; } function isSupportOfficeOnline(){ var filePath = '<%=filePath%>'; var fileType = '<%=fileType%>'; if(filePath == ''){ window.location.href="<%=basePath%>/contInfo/anlysisError.do?errorType=2"; }else if(fileType != ".docx"){ window.location.href="<%=basePath%>/contInfo/anlysisError.do?filePath="+filePath+"&errorType=1"; }else{ if(isIE()){ openWord(); }else{ window.location.href="<%=basePath%>/contInfo/anlysisError.do?filePath="+filePath+"&errorType=0"; } } } </script></head><body onload="InitEvent();isSupportOfficeOnline();" style="background-color: #ffffff;"><input type="hidden" name="filePath" id="filePath" value="${commonFile.filePath}"> <div> <table width="100%"> <tr> <td> <input type="button" onclick="saveToWeb()" name="保存" class="btn btn-info btn-sm" style="margin-top: 20px;float:right" value="保存"> <object classid="clsid:00460182-9E5E-11d5-B7C8-B8269041DD57" id="oframe" width="100%" height="100%" codebase="dsoFramer.CAB#version=2,2,1,2"> <param name="BorderStyle" value="1" /> <param name="TitlebarColor" value="52479" /> <param name="TitlebarTextColor" value="0" /> <param name="Menubar" value="0" /> <param name="Titlebar" value="0" /> <param name="Menubar" value="0" /> </object> <div style="display: none"> <!-- dsoframe事件 开始 --> <script type="text/javascript" language="jscript" for="oframe" event="OnDocumentOpened(str,obj)"> OnDocumentOpened(str, obj); </script> <script type="text/javascript" language="jscript" for="oframe" event="OnDocumentClosed()"> OnDocumentClosed(); </script> <!-- dsoframe事件 结束 --> </div> </td> </tr> </table> </div></body></html>
后台代码:
@RequestMapping(value = "/getWord.do")public void getWord(String filePath,HttpServletRequest request,HttpServletResponse response) {String upload_path = ConfigManager.getConfigValue("upload_path");String path = upload_path + "\\" + filePath;File file = new File(path);response.setHeader("Pragma", "No-cache");response.setHeader("Cache-Control", "no-cache");response.setHeader("Content-type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");response.setHeader("Content-Disposition", "attachment;filename=" + "asdas1.docx");response.setDateHeader("Expires", 0);FileInputStream fis = null;OutputStream os = null;try {fis = new FileInputStream(file);os = response.getOutputStream();int count = 0;byte[] buffer = new byte[1024 * 8];while ((count = fis.read(buffer)) != -1) {os.write(buffer, 0, count);os.flush();}} catch (Exception e) {e.printStackTrace();} finally {try {fis.close();os.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
@RequestMapping(value = "/saveToWeb.do")public void saveToWeb(HttpServletRequest request,HttpServletResponse response) throws Exception {String flag = "0";String filePath = "";FileItemFactory dfif = new DiskFileItemFactory();ServletFileUpload servletfileupload = new ServletFileUpload(dfif);try{List fileItems = servletfileupload.parseRequest(request); // 依次处理请求 Iterator iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { // 如果item是正常的表单域 String name = item.getFieldName(); String value = item.getString("UTF-8"); if(name.equals("filePath")){filePath=value;//附件标题赋值 } } else { //获取文件实体String upload_path = ConfigManager.getConfigValue("upload_path");File savefile = new File(upload_path + "\\" + filePath);item.write(savefile);} } flag = "0";}catch (Exception e) {flag = "1";}response.setHeader("Content-type","text/html;charset=UTF-8");//向浏览器发送一个响应头,设置浏览器的解码方式为UTF-8 OutputStream stream = response.getOutputStream(); stream.write(flag.getBytes("UTF-8"));}
0 0
- dsoframer-在线编辑(读取保存服务器文档)
- 在线Office文档编辑ActiveX插件DsoFramer
- dsoframer控件-jsp在线编辑offic文档
- 关于dsoframer控件保存文档至服务器的问题
- dsoframer-在线编辑office文档,一款开源的由微软提供
- Dsoframer控件实现office在线编辑
- 使用dsoframer.ocx在线编辑word
- 在线编辑word文档 可保存到服务器
- 在线编辑word文档 可保存到服务器
- 在线编辑office文件 保存到服务器设置
- 保存在线word编辑的内容到服务器
- C# 文本文档操作——读取、保存、编辑
- 在线编辑word文档
- Office文档在线编辑
- 在线编辑word文档
- 在线编辑word文档
- 文档在线编辑收集
- 在线打开编辑文档
- zedboard初识
- 241. Different Ways to Add Parentheses
- CreateThread与_beginthread,内存泄漏为何因
- VIM配置---基础篇
- 实现捕获应用的运行时异常
- dsoframer-在线编辑(读取保存服务器文档)
- 特征-小波 频域
- 莫队算法
- HashMap实现原理分析
- 010editor脚本语法深入分析
- UE使用
- Android Support Library-FloatingActionButton
- 【MyBatis框架】高级映射-一对一查询
- CF 461C 模拟