zoukankan      html  css  js  c++  java
  • Ueditor富编辑器

    坑多的Ueditor富编辑器

    第一步:修改serverUrl: window.BASEPATH + "notice/word"

    第二部:添加依赖包

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.17</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.13</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>ooxml-schemas</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>openxml4j</artifactId>
        <version>1.0-beta</version>
    </dependency>
    <dependency>
        <groupId>fr.opensagres.xdocreport</groupId>
        <artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
        <version>1.0.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.13</version>
    </dependency>
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.8.3</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.cssparser</groupId>
        <artifactId>cssparser</artifactId>
        <version>0.9.25</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.3</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20160810</version>
    </dependency>
    <!-- emf转png -->
    <dependency>
        <groupId>org.freehep</groupId>
        <artifactId>freehep-graphicsio</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.freehep</groupId>
        <artifactId>freehep-graphicsio-emf</artifactId>
        <version>2.3</version>
    </dependency>
    <!-- wmf转svg -->
    <dependency>
        <groupId>net.arnx</groupId>
        <artifactId>wmf2svg</artifactId>
        <version>0.9.5</version>
    </dependency>
    <!-- svg转jpg --><!-- 缺少 batik-all-1.7.jar-->
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis-ext</artifactId>
        <version>1.3.04</version>
    </dependency>
    <dependency>
    <groupId>com.gitee.qdbp.thirdparty</groupId>
        <artifactId>ueditor</artifactId>
        <version>1.4.3.3</version>
    </dependency>

    第三部:写controller

    @RequestMapping(value = "word")
        public void word(HttpServletRequest request,HttpServletResponse response) throws Exception{
            String rootPath = request.getSession()
                    .getServletContext().getRealPath("/");
            boolean isMultipart = ServletFileUpload.isMultipartContent(request);
            FileItem fileItem = null;
            if (isMultipart) {
                DiskFileItemFactory factory = new DiskFileItemFactory(1024 * 1024 * 20, null);
                ServletFileUpload uploader = new ServletFileUpload(factory);
        
                uploader.setHeaderEncoding("UTF-8");
                uploader.setSizeMax(1024 * 1024 * 20);
                
                List<FileItem> fileItems = uploader.parseRequest(request);
                for (FileItem item : fileItems) {
                    if (!item.isFormField()) {
                        fileItem = item;
                    }
                }
            }  
            try {
                String exec = new ActionEnter(request, rootPath, fileItem).exec();
                PrintWriter writer = response.getWriter();
                writer.write(exec);
                writer.flush();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    <textarea id="container" name = "container" type="text/plain" style=" 1200px;"></textarea>
    
    <!-- 配置文件 -->
    <script type="text/javascript" src="js/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="js/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="js/ueditor/lang/zh-cn/zh-cn.js"></script>

    var ue = UE.getEditor('container',{
         toolbars: [
                        ['undo', 'redo','importword','print','cleardoc']
                   ],
         initialFrameWidth : 690,
    });
    
    ue.ready(function() {
        ue.setHeight(300);
        ue.setContent('');
    })

     二次加载ueditor

    UE.delEditor('container'); 
    var ue = UE.getEditor('container',{
        toolbars: [
            ['undo', 'redo','importword','print','cleardoc']
        ],
        initialFrameWidth : 690,
    });
    ue.ready(function() {
        ue.setHeight(300);
        ue.setContent('');
        ue.setContent(dgmcfjData);
    })
    //ueditor.all.js UE.plugin.register(
    'importword', function (){ domUtils.on(input, 'change', function(){ me.execCommand('cleardoc');//清空内容 //var message = document.getElementById('edui1_message_holder'); //替换为 var message = document.getElementById(me.ui.id + '_message_holder'); }) })
  • 相关阅读:
    [调参]batch_size的选择
    [调参]CV炼丹技巧/经验
    [Pytorch]Pytorch加载预训练模型(转)
    [PyTorch]论文pytorch复现中遇到的BUG
    [Opencv]图像的梯度与边缘检测(转)
    freemodbus移植、实例及其测试方法
    eclipse的C/C++开发搭建
    ROS安装
    U-boot移植
    QT开发实战一:图片显示
  • 原文地址:https://www.cnblogs.com/sunBinary/p/10616493.html
Copyright © 2011-2022 走看看