1、首先去官网下载Ueditor,选择UTF-8版本
下载地址: http://ueditor.baidu.com/website/download.html#ueditor
2、在项目工程里面导入,新建一个Ueditor的文件夹,把解压之后的全部东西放进去。
3、新建一个JSP页面,并在页面上引用Ueditor的JS文件,路径自己调整。
onload = function() {
editor2 = UE.getEditor('container');
var notificationContent = $("#notificationContent").val(); //将内容显示到编辑器中
editor2.ready( function() {
editor2.setContent(notificationContent);
} );
}
下载地址: http://ueditor.baidu.com/website/download.html#ueditor
2、在项目工程里面导入,新建一个Ueditor的文件夹,把解压之后的全部东西放进去。
3、新建一个JSP页面,并在页面上引用Ueditor的JS文件,路径自己调整。
<!-- 配置文件 --> <script type="text/javascript" src="ueditor/ueditor.config.js"></script> <!-- 编辑器源码文件 --> <script type="text/javascript" src="ueditor/ueditor.all.js"></script>
4、在页面上新建一个textarea的标签,如下:
<textarea id="container" name="container"
style="width: 800px; height: 400px; margin: 0 auto;">
</textarea>
5、实例化编辑器,这里用的是替代法,即把textarea替换为Ueditor编辑器
<!-- 实例化编辑器 -->
<script type="text/javascript">
var ue = UE.getEditor("container");
</script>
到此,基本配置就完了。
后台获取数据,在后台里面:
String word_content = request.getParameter("container"); 获取页面上的name="container "就行了
这里说一下自己嵌入时编写代码遇到的问题,在onload中添加:var editor2;
onload = function() {
editor2 = UE.getEditor('container');
var notificationContent = $("#notificationContent").val(); //将内容显示到编辑器中
editor2.ready( function() {
editor2.setContent(notificationContent);
} );
}
切记:editor如果没有实例化完毕,无论setContent还是getContent调用都会提示错误,如果想要在onload中调用需要添加editor.ready(function(){xxxxxxx具体操作xxxxxxx});