富文编辑器使用,Ueditor后端配置项没有正常加载,上传插件不能正常使用!

一、使用(我这里使用的是jsp版本的富文本编辑器)

1)

下载ueditor

下载地址:http://ueditor.baidu.com/website/download.html

2)

解压缩文件,并把文件夹名改为ueditor

ueditor\jsp\lib路径下有commons-codec-1.9.jar、commons-fileupload-1.3.1.jar、commons-io-2.4.jar、json.jar、ueditor-1.1.2.jar五个jar包

3)

把整个ueditor文件夹复制到工程WebRoot下;

把ueditor\jsp\lib文件夹下的五个jar包复制到WebRoot—>WEB-INF—>lib文件夹下(我就是放错了文件夹,导致编辑器可以使用,但是无法使用图片上传功能)

4)

在jsp文件中先引入ueditor.config.js、ueditor.all.js文件

 </script>

 <!-- 配置文件 -->

 <script type="text/javascript" src="ueditor.config.js"></script>

 <!-- 编辑器源码文件 -->

 <script type="text/javascript" src="ueditor.all.js"></script>

5)

页面中这么使用

<!-- 加载编辑器的容器 -->

<script id="container" name="content" type="text/plain">

这里写你的初始化内容

<!-- 实例化编辑器 -->

<script type="text/javascript">

var ue = UE.getEditor('container');

</script>

6)

效果图

7)

设置和读取编辑器的内容

var ue = UE.getContent();

//对编辑器的操作最好在编辑器ready之后再做

ue.ready(function() {

    //设置编辑器的内容

    ue.setContent('hello');

    //获取html内容,返回: <p>hello</p>

    var html = ue.getContent();

    //获取纯文本内容,返回: hello

    var txt = ue.getContentTxt();

});

猜你喜欢

转载自blog.csdn.net/kelly921011/article/details/88425866