解决springboot MultipartFile文件上传遇到的问题
1.ajax传过去的参数在controller接受不到
解决:在contoller中增加@RequestParam
例如:saveUploadFile(@RequestParam("file")MultipartFilefile,HttpServletRequestrequest)
2.org.springframework.web.multipart.support.MissingServletRequestPartException:Requiredrequestpart'file'isnotpresent
将ajax请求的contextType改成是“multipart/form-data;charset=utf-8”,原来是“text/html;charset=UTF-8”格式都是不对的。还是会出现问题,最后改到contentType:false,请求不使用contentType
3.org.thymeleaf.exceptions.TemplateInputException:Errorresolvingtemplate"test/upload",templatemightnotexistormightnotbeaccessiblebyanyoftheconfiguredTemplateResolvers
解决:是contorller层没有返回数据,要么返回String直接指向页面,要么返回数据值输出
总结
以上所述是小编给大家介绍的解决springbootMultipartFile文件上传遇到的问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西