1.ueditor/jsp/config.json,指定一台服务器作为上传服务器,manager为webapp目录:
"imageUrlPrefix": "http://172.16.224.4:8081/manager", /* 图片访问路径前缀 */
"fileUrlPrefix": "http://172.16.224.4:8081/manager", /* 文件访问路径前缀 */
2.ueditor/jsp/controller.jsp,加入允许跨域:
<%@ page language="java" contentType="text/html; charset=UTF-8"
import="com.baidu.ueditor.ActionEnter" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%
request.setCharacterEncoding( "utf-8" );
//跨域时需要设置http头信息以返回参数给源地址
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Headers", "X-Requested-With,X_Requested_With");
response.setHeader("Content-Type" , "text/html");
String rootPath = application.getRealPath( "/" );
out.write( new ActionEnter( request, rootPath ).exec() );
%>
3.ueditor/ueditor.config.js,指定上传的地址:
window.UEDITOR_CONFIG = {
//为编辑器实例添加一个路径,这个不能被注释
UEDITOR_HOME_URL: URL
// 服务器统一请求接口路径
// , serverUrl: URL + "jsp/controller.jsp"
//"src/main/webapp/jslib/plugins/ueditor/jsp/controller.jsp"
//跨域不支持单图上传
, serverUrl: "http://172.16.224.4:8081/manager/jslib/plugins/ueditor/jsp/controller.jsp"
//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
, toolbars: [[