现在有没有一种富文本编辑器能够直接从 word 中复制粘贴公式的?
这种方法是servlet,编写好在web.xml里配置servlet-class和servlet-mapping即可使用
后台(服务端)java服务代码:(上传至ROOT/lqxcPics文件夹下)
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@
page contentType="text/html;charset=utf-8"%><%@
page import = "Xproer.*" %><%@
page import="org.apache.commons.lang.StringUtils" %><%@
page import="org.apache.commons.fileupload.*" %><%@
page import="org.apache.commons.fileupload.disk.*" %><%@
page import="org.apache.commons.fileupload.servlet.*" %><%
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List files = null;
try
{
files = upload.parseRequest(request);
}
catch (FileUploadException e)
{
out.println("上传文件异常:"+e.toString());
return;
}
FileItem imgFile = null;
Iterator fileItr = files.iterator();
while (fileItr.hasNext())
{
imgFile = (FileItem) fileItr.next();
if(imgFile.isFormField())
{
String fn = imgFile.getFieldName();
String fv = imgFile.getString();
if(fn.equals("uname")) uname = fv;
if(fn.equals("upass")) upass = fv;
}
else
{
break;
}
}
Uploader up = new Uploader(pageContext,request);
up.SaveFile(imgFile);
String url = up.GetFilePathRel();
out.write(url);
response.setHeader("Content-Length",url.length()+"");
%>
配置web.xml
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
index.jsp
实现后的效果,能够批量上传word中的全部图片,大幅度提升图片上传效率。而且能够保留Word样式。
图片上传完后,编辑器里面的图片地址也全部都改成了服务器的图片地址了,
所有代码已经全部传到网上,有需要的朋友可以直接下载使用,http://blog.ncmem.com/wordpress/2019/08/07/javaword图片上传控件/
讨论群:223813913