<form action="update.do"method="post" enctype="multipart/form-data" > 文件上传:<input name="myfile" type="file"><br> <input type="submit" value="上传"> </form>
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("myfile"); if (!file.isEmpty()) { System.out.println("非空"); }else { System.out.println("空的"); }