第一步:
一、去ue官网下载他的源码(已经有的了就略过)
二、Eclipse新建项目ueditorDemo
项目目录如下:
application.properties配置如下:
第二步:
一、解压下载的源码——然后打开项目把源码拖进项目的resources/static中去
二、在WEB-INF下新建jsp文件夹 添加一个index.jsp
三、将static中ueditor文件下的index.html中的内容复制到index.jsp中,修改一下js的路径,基本如下
然后启动项目去访问:http://localhost:8080/ueditorDemo/
这时候访问页面成功 但是后台还没配置:F12打开Console发现报错
这时候查看请求会发现 http://localhost:8080/ueditorDemo/ueditor/jsp/controller.jsp?action=config&&noCache=1595814465808这个请求服务器的请求
说明我打开这个页面它就去请求我的后台了
第三步(配置后台):
一、打开static中ueditor文件下的ueditor.config.js
将 serverUrl 改为 "ueditor/config1" 如下图:
二、下面就要把源码里面的jsp下的jar包,add到项目中去
这里有两种方式来配置 分别建了Demo1Controller 跟Demo2Controller 两个来区别 (推荐第二种)
只演示第一种:
Demo1Controller.class
package com.demo.Controller;
import java.io.File;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.demo.entity.Results;
@Controller
public class Demo1Controller {
/**
* 这里有两种方式,推荐第二种