解决springboot MultipartFile文件上传遇到的问题
作者:befroe_You
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 直接指向页面,要么返回数据值输出
总结
以上所述是小编给大家介绍的解决springboot MultipartFile文件上传遇到的问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章:
- springboot与mybatis整合实例详解(完美融合)
- 在SpringBoot下读取自定义properties配置文件的方法
- Spring Boot 日志配置方法(超详细)
- SpringBoot + Spring Security 基本使用及个性化登录配置详解
- springboot @ConditionalOnMissingBean注解的作用详解
- Springboot Thymeleaf实现HTML属性设置
- springboot项目打成war包部署到tomcat遇到的一些问题
- springboot如何读取配置文件(application.yml)中的属性值
- 详解eclipse下创建第一个spring boot项目
- Spring Boot 4.0对于Java开发的影响和前景