admin 管理员组

文章数量: 887031


2023年12月21日发(作者:英文名shelly)

Java Web Office 文档在线编辑

1、创建页面

Office在线编辑

height="700"

codebase="">

if(())

{

("保存文件到服务器!");

bFile("");

var sPath= ("服务器文件路径:", "");

b)

if(())

{

}

();

if(())

{

}

if(y())

{

}

else

{

}

("The 't been modified!");

("The been modified!");

}

文档!">

2、创建文件保存到服务器Servlet

package tmp;

import edInputStream;

import edOutputStream;

import ;

import .;

import ption;

import tream;

import ;

import tException;

import rvlet;

import rvletRequest;

import rvletResponse;

import nts;

import s.;

import s.;

public class UpLoadServlet extends HttpServlet

{

public void init() throws ServletException

{

}

public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException

{

// process(req, resp);

process(req);

}

public void process(HttpServletRequest request) throws IOException

{

// 读取控件输入流

InputStream stream = utStream();

// 将输入流保存到文件

savefile = new (Constants. + UUID() + ".doc");

byte[] bytes = new byte[1024];

int len;

while ((len = (bytes)) != -1)

{

save(bytes, 0, len);

save();

}

// 关闭文件

();

// 关闭输入流

save();

}

public void process(HttpServletRequest request, HttpServletResponse response) throws IOException

{

Servlet upload = new Servlet();

InputStream stream = null;

BufferedInputStream bis = null;

BufferedOutputStream bos = null;

try

{

stream = utStream();

String = "";

String fileId = UUID().toString() + (("."));// 取扩展名

bis = new BufferedInputStream(stream);

bos = new BufferedOutputStream(new (new + fileId)));

(bis, bos, true);

ter().write("{success:true}");

} catch (Exception e)

{

ter().write(("{success:false,message:'%s'}", sage()));

} finally

{

if (stream != null)

{

try

{

();

} catch (Exception e)

{

}

}

if (bis != null)

{

try

{

();

} catch (Exception e)

{

}

}

if (bos != null)

{

try

{

();

} catch (Exception e)

{

}

}

}

}

public void destroy()

{

}

}

3、配置

UpLoadServlet

UpLoadServlet

Servlet

UpLoadServlet

/UpLoadServlet

4、下载控件包

Office文档在线编辑OCX控件包


本文标签: 文件 服务器 保存 控件 输入