springboot集成ueditor

一、背景

任何web项目或多或少会用到富文本框,而富文本框又以百度富文本框(ueditor)最为全面实用。最近大多使用springboot框架,里面的上传文件是我自己封装的上传到远程fastdfs图片服务器,所以集成ueditor时遇到很多问题,今天得以解决。写下此文档可以给初次使用springboot集成ueditor的人借鉴,同时自己以后项目也可以复用。


二、添加pom依赖

		<!-- https://mvnrepository.com/artifact/cn.songxinqiang/com.baidu.ueditor -->
		<dependency>
			<groupId>cn.songxinqiang</groupId>
			<artifactId>com.baidu.ueditor</artifactId>
			<version>1.1.2-offical</version>
		</dependency>

三、下载ueditor

Ueditor官网下载 http://ueditor.baidu.com/website/  Jsp版本,或者下载我已经改好配置文件的

http://pan.baidu.com/s/1nu6RvzN 密码:v83n

下载后将其放到resources/static下


四、编写图片上传控制器

@RequestMapping(value = "/admin/upload", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> imgUpload3(MultipartFile upfile) {
System.out.println("开始上传");
Map<String, String> result = new HashMap<String, String>();
String path = "";
try {
path = fastDFSClientWrapper.uploadFile(upfile);
} catch (IOException e) {
System.out.println("富文本框图片上传错误");
// e.printStackTrace();
}
System.out.println(path);
File file = new File(path);
result.put("url", path);
result.put("size", String.valueOf(file.length()));
result.put("type",
file.getName().substring(file.getName().lastIndexOf(".")));
result.put("state", "SUCCESS");


return result;
}


五、修改配置文件



六、修改ueditor中的image.html文件


七、集成ueditor的html文件修改

引入js文件

   

需要插入ueditor的地方,类似下图

八、完成演示




  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值