UEditor是百度的编辑器,界面美观,功能强大,用起来还不错。
详见该链接http://ueditor.baidu.com/
一、下载
http://ueditor.baidu.com/download.html
二、部署
目前最新版本为1.1.7.3
下载下来的文件名为ueditor1.1.7.3.zip
把解压出来的ueditor文件夹整个复制到项目WebRoot下
1.页面<head>里增加以下代码
- <script type="text/javascript" charset="utf-8" src="ueditor/editor_config.js"></script>
- <script type="text/javascript" charset="utf-8" src="ueditor/editor_all.js"></script>
- <link rel="stylesheet" type="text/css" href="ueditor/themes/default/ueditor.css"/>
- <div id="newscontent"></div>
- <script type="text/javascript">
- var editor = new baidu.editor.ui.Editor();
- editor.render('newscontent');
- </script>
三、修改配置,增加上传
打开editor_config.js文件,修改URL的值
- var URL= "ueditor/";
文件上传默认用的是ueditor/server/upload/php/up.php进行上传的,如果用jsp上传,需要修改两个地方
1.修改ueditor/dialogs/image/image.html页面里第304行和ueditor/dialogs/wordimage/wordimage.html页面第82行,改为使用up.jsp进行上传,这里面用的是apache的fileupload组件,所以要导入apache commons组件中的fileupload和io这两个jar包
- url:'../../server/upload/jsp/up.jsp',
2.修改ueditor/server/jsp/up.jsp,指定文件的保存路径
- //保存文件路径
- String filePath = "uploadfiles";
- String realPath = "D:\\apache-tomcat-6.0.26\\webapps\\test\\"+filePath;