两种方式:
1.将多个文件置为同一个名称,放入数组
@RequestMapping(value="/item/store", method=RequestMethod.POST)
@ApiOperation(value = "添加幻灯片项", httpMethod = "POST", response = IBaseResult.class)
@ResponseBody
public IBaseResult storeItem(@ApiIgnore @ModelAttribute SlideshowItem slideshowItem
,@RequestParam("images") MultipartFile[] images
,HttpServletRequest request
){
......
}
2.将多个文件永不同的名称区分开
注意:requred = false,允许这个文件为空
@RequestMapping(value="/item/update/{slideshowItemId}", method=RequestMethod.POST
, consumes=MediaType.MULTIPART_FORM_DATA_VALUE,produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "修改幻灯片项", httpMethod = "POST", response = IBaseResult.class)
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(name="title",value="标题",dataType="String", paramType = "query")
,@ApiImplicitParam(name="ordering",value="排序号",dataType="Integer", paramType = "query")
})
public IBaseResult updateItem(@ApiIgnore @ModelAttribute SlideshowItem slideshowItem,
@PathVariable("slideshowItemId") Integer slideshowItemId
,@RequestParam(required=false,name="backGround") MultipartFile backGround
,@RequestParam(required=false,name="overturnBackGround") MultipartFile overturnBackGround
,@RequestParam(required=false,name="overturnFrontGround") MultipartFile overturnFrontGround
,HttpServletRequest request
) {......}