1.下载
http://ueditor.baidu.com/website/
2.将根目录下jsp/lib中的jar包添加到自己的项目中,主要是 ueditor-1.1.1.jar
3.新建jsp页面,引入3个js文件
<script type="text/javascript" src="${pageContext.request.contextPath }/ueditor/ueditor.config.js"></script> <!-- 这个文件在前面-->
<script type="text/javascript" src="${pageContext.request.contextPath }/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/ueditor/lang/zh-cn/zh-cn.js"></script>
4.参数配置
1)配置图片上传路径,对应后台控制器
ueditor.config.js文件中配置:serverUrl: URL + "jsp/controller.jsp"
此处最好加上前缀jsp,因为config.json的位置是在jsp中的.
2)后台参数配置
jsp/config.json文件中参数配置
"imageActionName": "uploadimage", /* 执行上传图片的action名称 ,<span style="color:#FF0000;">最好不要变</span>*/
"imageFieldName": "upfile", /* 提交的图片表单名称 */
"imageMaxSize": 2048000, /* 上传大小限制,单位B */
"imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
"imageCompressEnable": true, /* 是否压缩图片,默认是true */
"imageCompressBorder": 1600, /* 图片压缩最长边限制 */
"imageInsertAlign": "none", /* 插入的图片浮动方式 */
"imageUrlPrefix": "/<span style="color:#FF0000;">projectname</span>", /* 图片访问路径前缀 项目名称 */
"imagePathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}_filename", /* 上传保存路径,可以自定义保存路径和文件名格式 */
5.得到编辑器实例并且提交表单
<form action="jsp/saveData.do" method="post">
<script type="text/plain" id="editor" name="content" style="width:1024px;height:500px;"></script>
<input type="submit" value="提交"/>
</form>
<script type="text/javascript">
var ue = UE.getEditor('editor');
</script>