UMEditor配置
UMEditor配置
最近项目中需要用到富文本客户端。确定使用umeditor。首先在官网下载相应文件
http://ueditor.baidu.com/website/download.html
笔者选择的jsp版本的。
目录结构如下
下面讲讲配置整合的经过。
引入相应js 及css。要注意顺序。
jquery.min.jsthird-party/template.min.jsumeditor.min.jsumeditor.config.jsthemes/default/css/umeditor.min.css
页面定义div
<divtype="text/plain"id="career"name="career"Readonly="true"><scripttype="text/javascript">mini.parse();varum=UM.getEditor('career');</script>
整合完毕
umeditor.config.js是相应的配置文件,里面的说明比较全面。笔者需要自定义国际化和图片存储路径
写了两个js
functiongetPath(){//根路径varpathName=location.pathname;varhost='http://'+location.host;returnhost+pathName.substring(0,pathName.substr(1).indexOf('/')+1);}functiongetLanguage(){varlanguage=getCookie("language");if(null==language||""==language){language=navigator.browserLanguage?navigator.browserLanguage:navigator.language;}language=language.substring(0,2);if(language!="zh"){language="en";}else{language="zh-cn";}returnlanguage;}
在umeditor.config.js 配置时进行引用
,p_w_picpathPath:getPath()+"/"//是取图片时的路径,lang:getLanguage(),p_w_picpathUrl:URL+"jsp/p_w_picpathUp.jsp"//图片上传提交地址p_w_picpathUrl这个参数是p_w_picpathUp.jsp所在路径,如果配置不对上传图片会404(可以不改)
本人将图片另放一个自定义目录
首先修改p_w_picpathUp.jsp 中上传路径
注意要引入
<%@ page import="com.manage.common.util.Uploader" %>
注意自己的路径
默认是upload
修改setSavePath("img/upload") 中参数即可
同时还需修改Uploader.java 中获取绝对路径的方法
privateStringgetPhysicalPath(Stringpath){/*StringservletPath=this.request.getServletPath();StringrealPath=this.request.getSession().getServletContext().getRealPath(servletPath);returnnewFile(realPath).getParent()+"/"+path;*/returnthis.request.getSession().getServletContext().getRealPath("/")+"/"+path;}
自此完成配置图片上传自定义位置
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。