![](https://csdnimg.cn/release/download_crawler_static/85984947/bg6.jpg)
String exec = new ActionEnter(request, rootPath, “/config.json”).exec();
PrintWriter writer = response.getWriter();
writer.write(exec);
writer.flush();
writer.close();
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
/**
* Ueditor 上传文件
* 这里以上传图片为例,图片上传后,imgPath 将存储图片的保存路径,返回到编
辑器中做展示
* @param upfile
* @return
*/
@RequestMapping(“uploadimage”)
@ResponseBody
public Map uploadImage(@RequestParam(“upfile”) MultipartFile upfile,
HttpServletRequest request) throws IOException {
System.out.println(“上传图片!”);
//文件原名称
String fileName = upfile.getOriginalFilename();
// 保存文件的新名字
String timeFileName = DateHelper.getDateToString(new Date());
String nowName =
timeFileName+”_”+UUID.randomUUID()+fileName.substring(upfile.getOriginalFilename().lastI
ndexOf(“.”));
String uploadPath = ““;
if(!upfile.isEmpty()){
String path = “D:/science-2.0/”;
File f = new File(path);
if(!f.exists()){
// 第一次上传文件新建文件夹
f.mkdirs();
}
uploadPath = path+nowName;
//按照路径新建文件
File newFile = new File(uploadPath);