wangEditor显示文件上传失败

wangEditor显示文件上传失败

服务器显示文件是成功上传了并且out目录是有上传的图片的

相关截图:

https://img1.sycdn.imooc.com//climg/61e3e61709c4df1d04460325.jpg

相关代码:

 //实例化wangEditor富文本编辑器
    editor = new wangEditor(this.$refs.editor);
    //设置上传图片的地址
    editor.customConfig.uploadImgServer = '/book/management/upload';//设置图片上传地址
    //默认上传时使用的参数名
    editor.customConfig.uploadFileName = 'img';//设置图片上传参数
    editor.create();//创建wangEditor
    //设置初始内容
    editor.txt.html(this.form.description);
}

相关代码:

@PostMapping("/upload")相关代码:
public Map upload(@RequestParam("img") MultipartFile file, HttpServletRequest request) throws IOException {
    String uploadPath = request.getServletContext().getResource("/").getPath()+"/upload/";
    SimpleDateFormat sdft = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    String format = sdft.format(new Date());
    String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
    file.transferTo(new File(uploadPath+format+suffix));
    Map result = new LinkedHashMap();
    result.put("erron",0);
    result.put("data",new String[]{"/upload/"+format+suffix});
    return result;
}

https://img1.sycdn.imooc.com//climg/61e3e61809e8740e08680622.jpg

请老师看一下这是什么问题


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小尤 2022-01-16 18:30:02

同学你好,在此处老师在开发时,设置的返回值就是errno:0,errno为0表示上传成功,在课程15:51分有进行讲解。同学可以进行查看。

祝学习愉快!

  • 提问者 慕移动0250816 #1

    我的返回值和老师的一样,但是我显示图片上传失败,而且图片没有办法回填,是怎么回事

    2022-01-16 18:43:16
  • 提问者 慕移动0250816 #2

    搞定了参数敲错了



    2022-01-16 20:32:40
  • 好帮手慕小尤 回复 提问者 慕移动0250816 #3

    同学你好,同学解决了就好,继续加油!

    祝学习愉快!

    2022-01-17 09:33:38
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师