富文本UMeditor的使用

下载地址:http://ueditor.baidu.com/website/download.html#mini
一、前端配置
1、将下载的压缩包解压
2、将文件复制到项目webapp(webroot、webcontent )下
3、在需要使用到的页面引入css和js


<link href="/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">


<script type="text/javascript" src="/umeditor/third-party/template.min.js"></script>

<script type="text/javascript" charset="utf-8" src="/umeditor/umeditor.config.js"></script>

<script type="text/javascript" charset="utf-8" src="/umeditor/umeditor.js"></script>

<script type="text/javascript" src="/umeditor/lang/zh-cn/zh-cn.js"></script>

4、页面实例化Editor
在body中引入如下script ,定义宽高以及id

<div>
    <script type="text/plain" id="myEditor" style="width:600px;height:240px;"> 
    </script>
</div>

在body外
<script>
     //实例化编辑器
    var um = UM.getEditor('myEditor');
    um.addListener('blur', function () {
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus', function () {
        $('#focush2').html('')
    });
</script>

5、配置UMEDITOR_HOME_URL
在umeditor.config.js中定义
window.UMEDITOR_HOME_URL = “/umeditor/”;

二、后端配置(也可以直接使用压缩包里面的jar)
1、将解压后的 Uploader.java放在自己项目src中,改下顶部的包名路径
2、将commons-fileupload-1.2.2.jar拷贝到自己项目lib中
3、在imageUp.jsp引入的Uploader路径改为自己项目中Uploader.java的路径

<%@ page import="xxx.xxx.Uploader" %>

三、上传完图片保存到数据库时,如何删除掉src中所带的域名

在getAllPic方法中
将node.src的协议、主机名、端口号替换掉
var imgsrc = node.src.replace(window.location.protocol + '//' + window.location.hostname + ":" + window.location.port, '');

然后重新赋值
_src: imgsrc,src: imgsrc

四、img的src跨域请求

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值