1、ueditor.config.js 中,第一行
window.UEDITOR_HOME_URL = "/bss/js/ueditor/";
指定根目录
2、自定义Filter
package com.baidu.ueditor.filter;import javax.servlet.FilterChain; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter; public class UEditorFilter extends StrutsPrepareAndExecuteFilter{ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) { HttpServletRequest request = (HttpServletRequest) req; String url = request.getRequestURI(); try{ if (url.length() > 10 && "imageUp.jsp".equals(url.substring(url.length()-11))) { //umeditor chain.doFilter(req, res); }if (url.contains("/bss/js/ueditor/jsp/controller.jsp")) { //ueditor chain.doFilter(req, res); } else { super.doFilter(req, res, chain); } }catch(Exception e){ e.printStackTrace(); } } }
3、配置web.xml
StrutsPrepareFilter com.baidu.ueditor.filter.UEditorFilter StrutsPrepareFilter /*
经过以上配置富文本编辑器 就可以用了
4、使用示例My JSP 'ueditordemo.jsp' starting page
在com.baidu.ueditor.define.AppInfo.java 中
public static final int FULL_DISK = 801;//磁盘空间已满put(AppInfo.FULL_DISK, "\u8d85\u51fa\u78c1\u76d8\u7a7a\u95f4\u989d\u5ea6\uff0c\u4e0d\u5141\u8bb8\u4e0a\u4f20\u3002");
使用时:
//磁盘空间已满,返回信息return new BaseState(false, AppInfo.FULL_DISK);
6、自定义配置属性并读取
在config.json自定义属性
/* 自定义配置属性 add by xxx */"userConfigPath": false,
在com.baidu.ueditor.ConfigManager.java中读取配置
public MapgetConfig ( int type ) { Map conf = new HashMap (); String savePath = null; conf.put( "savePath", savePath ); conf.put( "rootPath", this.rootPath ); conf.put( "userConfigPath", this.jsonConfig.getBoolean( "userConfigPath" ));//add by xxx return conf; }
文件存储路径可以在配置文件中修改,也可以自定义
com.baidu.ueditor.upload.BinaryUploader.java
savePath = PathFormat.parse(savePath, originFileName);//返回到页面中的图片url String physicalPath = (String) conf.get("rootPath") + savePath;//图片存储的物理路径
根据自己的需求修改这两项的值,可以完成自定义。