admin 管理员组文章数量: 887031
2023年12月21日发(作者:英文名shelly)
Java Web Office 文档在线编辑
1、创建页面
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、配置
4、下载控件包
Office文档在线编辑OCX控件包
版权声明:本文标题:Java-Web-Office-文档在线编辑 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1703170240h440816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论