UEditor用法

UEditor百度是咋回事。界面美觀。強大,用起來還不錯。javascript


看到此連接http://ueditor.baidu.com/php

1、下載css

http://ueditor.baidu.com/download.html
html

2、部署java

眼下最新版本號爲1.1.7.3
web

下載下來的文件名稱爲ueditor1.1.7.3.zipapache

把解壓出來的ueditor目錄整個拷貝到項目WebRoot下瀏覽器

1.頁面<head>裏添加下面代碼tomcat

<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"/>
2.頁面<body>裏添加下面代碼
<div id="newscontent"></div>
<script type="text/javascript">
	var editor = new baidu.editor.ui.Editor();
	editor.render('newscontent');
</script>
打開瀏覽器。輸入對應地址。一個美麗的編輯器就出現了,但表情和上傳文件這塊還需要更改一下配置

3、改動配置。添加上傳app

打開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;
因此一切OK該,刷新測試!
相關文章
相關標籤/搜索