editor.md使用——图片上传没回显url

##楔子

使用editor.md 图片上传成功后没回显图片URL,最终发现是返回json 中success 类型导致
##使用记录

这里写图片描述

上面的图片记录了图片URL出现没没出现的 2中情况。下面代码给出解释。最主要的问题是/*resultJs.put("success", "1");此处不要写 字符串的"1",只是写为数字不要带引号*/

	@ResponseBody
	@RequestMapping("/blog/upFile")
	public JSON articleUpFile(HttpServletRequest req, @RequestParam("editormd-image-file") MultipartFile picpaths) {
		String url = "blog/" + SysUtils.getDateStr() + "/";
		File file = new File(SysConstant.UP_FILE, url);
		if (!file.exists() && file.mkdirs()) {
		}
		JSONObject resultJs=new JSONObject();
		String upPicFileName = SysUtils.getUpPicFileName();
		file = new File(file, upPicFileName);
		url = url + upPicFileName;
		try {
			picpaths.transferTo(file);
			/*resultJs.put("success", "1");此处不要写 字符串的"1",只是写为数字不要带引号*/
			resultJs.put("success", 1);
			resultJs.put("message", "上传成功");
			resultJs.put("url",SysConstant.PICURL + url);
		} catch (IllegalStateException | IOException e) {
			resultJs.put("success", 0);
			resultJs.put("message", "上传失败");
		}
		return resultJs;
	}

##图片上传后台接收为何是editormd-image-file

这里写图片描述
从上图中可以看出,editor工具构造的file字段是editormd-image-file

总有人问,为啥上传不会回显 ,这个里面有个 Demo,可以参考,https://blog.csdn.net/u012848709/article/details/103290253

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 15
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值