本文主要是介绍【知了堂学习笔记】_springMVC_文件上传_错误_Required CommonsMultipartFile parameter 'file' is not present,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
请关注“知了堂学习社区”,地址:http://www.zhiliaotang.com/portal.php
今天的学习了文件上传出现了:
Required CommonsMultipartFile parameter ‘file’ is not present
开始一直以为是@RequestParm(“file”)参数的传递问题:
public void singleFlieUpload(@RequestParam("file") CommonsMultipartFile commonsMultipartFile, HttpServletRequest request, HttpServletResponse response) {...}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body><form action="/ssm/upload/singlefileupload.do" method="post" enctype="multipart/form-data"><input type="file" name="file"><input type="submit"></form></body>
</html>
粘贴复制很多遍以后发现,还是不行,百度之后,得到灵感
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"p:maxUploadSize="5242880"p:maxInMemorySize="4096"p:defaultEncoding="UTF-8"></bean>
配置文件中的id是不能随便更改的,必须是multipartResolver
以此记录!!
这篇关于【知了堂学习笔记】_springMVC_文件上传_错误_Required CommonsMultipartFile parameter 'file' is not present的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!