I tried various permutation an combination and googled as well,when I am uploading xsl file with multiplesheet i am getting following Exception-
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: Stream closed] with root cause java.io.IOException: Stream closed
Below is my code-
<form name="upload" th:action="@{/util/uploadExcel}" action="/util/uploadExcel" enctype="multipart/form-data" method="post">
<input type="file" name="fileData" path="fileData" />
<input type="submit"/>
</form>
@Controller
@RequestMapping("/util")
public class UtilController {
@RequestMapping(value=("/uploadExcel"),headers=("content-type=multipart/*"),method= RequestMethod.POST)
public ModelAndView uploadExcel(@RequestParam("fileData") CommonsMultipartFile file,BindingResult result) {
utilService.uploadData(file);
ModelAndView modelAndView = new ModelAndView("paidAnalysis/index");
return modelAndView;
}
@Bean
public CommonsMultipartResolver multipartResolver() {
return new CommonsMultipartResolver();
}
}
MoreOver I have added dependency for 'commons-fileupload' in my project.
When I upload any csv file other than xsl I am getting-
There was an unexpected error (type=Bad Request, status=400). Required CommonsMultipartFile parameter 'fileData' is not present