MultipartFile 动态决定是否上传文件,解决不上传文件报错
controller
接收参数 用 HttpServletRequest 代替 @RequestParam() 接收参数
picFile 前台 传文件的参数名字 , 这样 前段 传 null 就可以 不必须 存文件了
MultipartFile picFile = null; boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart){ MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class); picFile = multipartRequest.getFile("picFile"); }
https://blog.csdn.net/zhaofuwu/article/details/52694487
https://blog.csdn.net/m0_38004838/article/details/78286067
springMVC的 https://blog.csdn.net/chenchunlin526/article/details/70945877