zoukankan      html  css  js  c++  java
  • UEditor编辑器上传图片开发流程

    在ueditor目录下找到uedior.config.js,找到如下三行:

    ,imageUrl: "<%=path %>/controller.json" //图片上传提交后台对应的地址,路径固定为*/controller.*
    ,imagePath: "<%=path %>/ueditor/" //图片在服务器上的存储目录
    ,imageFieldName: "upload" //后台对应接收image的参数名

    或者:

    var ueditor = UE.getEditor('myEditor',{
        imageUrl: "<%=path %>/servlet/UploadServlet", //图片上传提交后台对应的地址
        imagePath: "<%=path %>/ueditor/",  //图片在服务器上的存储目录
        imageFieldName: "upload"  //后台对应接收image的参数名
    });

    注意:记得在uedior.config.js配置文件中把"serverUrl"注释掉

    在/ueditor/_src/plugins/simpleupload.js文件中,把link = me.options.imageUrlPrefix + json.url; 改为link = getRootPath()+json.url;

    最后配置服务器返回的数据格式,这需要这服务器端进行修改。对应于后台接收上传图片的那个controller,返回的格式需如下:

    {'url':'60391393848223.jpg','title':'p1999637039.jpg','original':'p1999637039.jpg','state':'SUCCESS'}

    注意:url用相对路径,这样就OK了。

    //js获取项目根路径,如: http://localhost:8083/uimcardprj
    
    function getRootPath(){
    
        //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
    
        var curWwwPath=window.document.location.href;
    
        //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
    
        var pathName=window.document.location.pathname;
    
        var pos=curWwwPath.indexOf(pathName);
    
        //获取主机地址,如: http://localhost:8083
    
        var localhostPaht=curWwwPath.substring(0,pos);
    
        //获取带"/"的项目名,如:/uimcardprj
    
        var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    
        //return localhostPaht + projectName;
    
        return localhostPaht+"/";
    
    }
  • 相关阅读:
    zabbix
    Tomcat 部署Web应用
    WebLogic
    WebLogic部署集群和代理服务器
    WebLogic 中的基本概念
    GIT详解和GITHUB
    Tomcat 内存溢出对应解决方式
    apache和tomcat区别
    数据库介绍
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
  • 原文地址:https://www.cnblogs.com/linjiqin/p/3729281.html
Copyright © 2011-2022 走看看