代码拉取完成,页面将自动刷新
下面演示在spring mvc的环境下使用修改版的方法,maven项目为例
修改版本(以及未修改代码版本)均上传到maven中央仓库
修改版的坐标
<dependency>
<groupId>cn.songxinqiang</groupId>
<artifactId>com.baidu.ueditor</artifactId>
<version>1.1.2-edit-1.0</version>
</dependency>
未修改版,只需将版本号修改为1.1.2-offical
官方给出的配置文件,放到src/main/resources
里面,文件名为ueditor.config.json
,内容和管饭过得无其他不一样
创建控制器作为专门的入口控制器,实现ServletContextAware
接口,以实现对项目根路径的获取
关键的是入口方法
@Controller
@RequestMapping("/ued")
public class UeditorController implements ServletContextAware {
private String rootPath;
@RequestMapping("/ueditor")
@ResponseBody
public String ueditorConfig(HttpServletRequest request, HttpServletResponse response) {
return new ActionEnter(request, rootPath, UeditorController.class.getClassLoader()
.getResource("ueditor.config.json").getPath()).exec();
}
@Override
public void setServletContext(ServletContext servletContext) {
rootPath = servletContext.getRealPath("/");
}
}
其中UeditorController.class.getClassLoader().getResource("ueditor.config.json").getPath()
是获取配置文件的具体路径,
可能需要根据实际进行修改
使用上面的入口,在前端的配置需要修改配置文件ueditor.config.js
的入口为如下内容
// 服务器统一请求接口路径
, serverUrl: content + "/ued/ueditor"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。