JAVA判断上传表单中file是否为空

<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("空的");
        }

 

转载于:https://www.cnblogs.com/koal/p/4491432.html

你可能感兴趣的:(java)