UEditor 前后端分离(vue+java)

一.前期准备工作

后台代码以及配置
1. UEditor官方文档:

http://fex.baidu.com/ueditor/#server-deploy

2.官方下载源码包:http://ueditor.baidu.com/website/download.html#ueditor

在这里插入图片描述

3.下载源码包,解压
根据目录…\ueditor-1.4.3.3\jsp\src\com\baidu\ueditor将ueditor文件复制到java项目的src下,如果是idea放在 src\main\java\com下
4.在解压的源码包里根据…\ueditor-1.4.3.3\jsp找到config.json文件并且将该文件复制到src/main/resource下
5.导入相关的jar包

在pom.xml:

    <!--富文本编辑器-->
    <!--json包-->
    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20190722</version>
    </dependency>

    <!--commons-io包-->
    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.6</version>
    </dependency>

    <!--commons-fileupload-->
    <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.4</version>
    </dependency>
    
    <!--commons-codec-->
    <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.13</version>
    </dependency>
6.修改ConfigManager.java文件,把 this.originalPath 修改为src/main/resources/config.json,IDEA直接修改为 config.json即可。然后注释掉
        if ( contextPath.length() > 0 ) {
			this.originalPath = this.rootPath + uri.substring( contextPath.length() );
		} else {
			this.originalPath = this.rootPath + uri;
		}

见图:
在这里插入图片描述

7.新建 controller
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

@Controller
public class UeditorController {
    private static final Log log = LogFactory.getLog(UeditorController.class);
	@RequestMapping("/config")
	public void config(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, JSONException {
		response.setContentType("application/json");
		String rootPath = request.getSession().getServletContext().getRealPath("/");
		try {
			ActionEnter actionEnter = new ActionEnter(request, rootPath);
			String exec=actionEnter.exec();
			PrintW
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值