org.springframework.boot
spring-boot-starter-thymeleaf
org.json
json
20190722
commons-fileupload
commons-fileupload
1.3.1
commons-codec
commons-codec
1.9
commons-io
commons-io
2.4
第二步:下载Ueditor源代码并将打包后得到的dist目录中内容拷贝到SpringBoot项目中。
下载地址:https://github.com/fex-team/ueditor/tree/dev-2.0.0
注意:为了方便,我将config.json放在ueditor的根目录中了。
第三步:运行项目,访问路径http://localhost:8080/ueditor/index.html,打开如下页面则成功:
第四步:当用户上传的图片太大时,为了不让Ueditor不出现水平滚动轴,可以修改ueditor.all.js文件以及ueditor.all.mini.js文件(选做):
第五步:修改ueditor.config.js文件,在其中指定Ueditor请求的服务器端的路径:
@Controller
@RequestMapping(“/ueditor”)
public class UEditorController {
@RequestMapping(value=“/config”)
public void config(HttpServletRequest req,HttpServletResponse resp) {
resp.setContentType(“application/json”);
String rootPath = req.getSession().getServletContext().getRealPath(“/”);
try {
String exec = new ActionEnter(request, rootPath).exec();
PrintWriter writer = resp.getWriter();
writer.write(exec);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
上面请求的完整路径/ueditor/config,对应
第七步:修改config.json文件,为其添加一个表示上传资料基本路径的变量basePath。
第八步:修改BinaryUploader的save()方法的代码如下:
public static final State save(HttpServletRequest request,Map<String, Object> conf) {
FileItemStream fileStream = null;
boolean isAjaxUpload = request.getHeader(“X_Requested_With”) != null;
if (!ServletFileUpload.isMultipartContent(request)) {
return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
}
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
if (isAjaxUpload) {
upload.setHeaderEncoding(“UTF-8”);
}
try {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile multipartFile = multipartRequest.getFile(conf.get(“fieldName”).toString());
if (multipartFile == null) {
return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
}
String savePath = (String) conf.get(“savePath”);
//String originFileName = fileStream.getName();
String originFileName = multipartFile.getOriginalFilename();
String suffix = FileType.getSuffixByFilename(originFileName);
originFileName = originFileName.substring(0,
originFileName.length() - suffix.length());
savePath = savePath + suffix;
long maxSize = ((Long) conf.get(“maxSize”)).longValue();
if (!validType(suffix, (String[]) conf.get(“allowFiles”))) {
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
}
savePath = PathFormat.parse(savePath, originFileName);
String basePath = (String) conf.get(“basePath”);
String physicalPath = basePath + savePath;
InputStream is = multipartFile.getInputStream();
State storageState = StorageManager.saveFileByInputStream(is,
physicalPath, maxSize);
is.close();
if (storageState.isSuccess()) {
storageState.putInfo(“url”, PathFormat.format(savePath));
storageState.putInfo(“type”, suffix);
storageState.putInfo(“original”, originFileName + suffix);
}
return storageState;
}catch (IOException e) {
}
return new BaseState(false, AppInfo.IO_ERROR);
}
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
![img](https://img-blog.csdnimg.cn/img_convert/59f9f990a75360396cf01db851e644c3.jpeg)
总结
我们总是喜欢瞻仰大厂的大神们,但实际上大神也不过凡人,与菜鸟程序员相比,也就多花了几分心思,如果你再不努力,差距也只会越来越大。实际上,作为程序员,丰富自己的知识储备,提升自己的知识深度和广度是很有必要的。
Mybatis源码解析
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
菜鸟程序员相比,也就多花了几分心思,如果你再不努力,差距也只会越来越大。实际上,作为程序员,丰富自己的知识储备,提升自己的知识深度和广度是很有必要的。
Mybatis源码解析
[外链图片转存中…(img-OR8WrQVS-1712684125943)]
[外链图片转存中…(img-SYhpMHNh-1712684125944)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!