HTTP Status 400-Required MultipartFile parameter 'file' is not present




Asked on August 05, 2014
Hi All,
I am creating a Spring MVC application to upload the file. My controller is like

@RequestMapping(value="/upload", method=RequestMethod.POST )
    public @ResponseBody String upload(@RequestParam("file") MultipartFile file){
}

And the jsp is 

<form method="POST" enctype="multipart/form-data"
action="upload">
File to upload: <input type="file" name="file"><br /> 
<input type="submit" value="Upload"> Press here to upload the file!
</form>


Unable to understand why  I  am getting error on browser as

HTTP Status 400 - Required MultipartFile parameter 'file' is not present

type Status report

message Required MultipartFile parameter 'file' is not present

description The request sent by the client was syntactically incorrect.
Apache Tomcat/7.0.42




Replied on August 09, 2014
Check for below jar, it you have gradle it will look like


dependencies {
   compile 'org.springframework.boot:spring-boot-starter-web:1.1.4.RELEASE'
   compile 'org.springframework.boot:spring-boot-starter-security:1.1.4.RELEASE'
   compile 'javax.servlet:jstl:1.2'
   compile 'commons-fileupload:commons-fileupload:1.3.1'
}




Write Answer











©2024 concretepage.com | Privacy Policy | Contact Us