Ueditor跨域上传文件设置

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: [[

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值