1,需要添加Maven包
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
2,在spring.xml中配置相应bean
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="utf-8" />
<property name="maxUploadSize" value="10485760000" />
<property name="maxInMemorySize" value="40960" />
</bean>
3,Controller层
@RequestMapping(value = "upload_build")
@ResponseBody
public int uploadBuild(@RequestParam("file") MultipartFile file) throws IOException {
List<List<List>> lists = ExcelUtil.readExcelIs(file.getInputStream());
if(lists!=null){
communityService.addBuilding(lists);
return 1;
}
return 0;
}