springboot MultipartFile文件上传遇到的问题
1.ajax传过去的参数在controller接受不到
解决:在contoller中增加@RequestParam
例如:saveUploadFile( @RequestParam("file") MultipartFile file,HttpServletRequest request)
2.org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present
将ajax 请求的contextType 改成是“multipart/form-data; charset=utf-8”,原来是“text/html; charset=UTF-8”格式都是不对的。还是会出现问题,最后改到 contentType: false,请求不使用contentType
3.org.thymeleaf.exceptions.TemplateInputException: Error resolving template "test/upload", template might not exist or might not be accessible by any of the configured Template Resolvers
解决:是contorller层没有返回数据,要么返回String 直接指向页面,要么返回数据值输出
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)