我正在使用 Spring Boot 来测试上传功能,并收到“Required MultipartFile parameter 'file' is not present”错误。当它部署外部 tomcat 服务器时。但它与spring boot tomcat插件一起正常工作以下是1)JSP,2)控制器3)配置属性1)<form id="initialUploadForm" action="${root}/upload/uploadCapFile" enctype="multipart/form-data" method="post"> <table align="left" width="50%" cellspacing="0" cellpadding="5" border="0" class="formTable"> <tr> <td><label class="">Add Cap File : </label></td> <td><input type="file" name="file" style="width:100%;"/></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td> </td> <td><input class="btn btn-success" type="submit" value="Upload Data" id="btnInitialUpload"/></td> </tr> <tr> <td colspan="2"> </td> </tr> </table></form>
2 回答
繁星淼淼
TA贡献1775条经验 获得超11个赞
将此代码放入配置文件
@Bean
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
multipartResolver.setMaxUploadSize(-1);
return multipartResolver;
}
子衿沉夜
TA贡献1828条经验 获得超3个赞
尝试添加multipart/form-data
方法签名。
@RequestMapping(value = "uploadCapFile", method = RequestMethod.POST,headers = "content-type=multipart/form-data")
添加回答
举报
0/150
提交
取消