Struts 2 File Upload Interceptor configuration problems

前端 未结 4 1379
我寻月下人不归
我寻月下人不归 2021-02-09 08:11

I\'m having two problems when trying to configure the Struts 2 File Upload Interceptor in my application. I want to change the parameter maximumSize (the default va

4条回答
  •  不要未来只要你来
    2021-02-09 08:38

    First use validate method in your action file........

    public void validate(){
    
      if(getFileUpload() !=null){
    
       System.out.println("======File size validation before upload: size in bytes: "+getFileUpload().length());
    
        if(getFileUpload().length()>202400){   
    
    //Give the size in bytes whatever you want to take
    
        addActionError("File is too large ! Select less than 200Kb file");
    
          }else{
    
        addActionMessage("File Uploaded successfully!");
    
         }
       }
    }
    

    For complete code,please visit http://knowledge-serve.blogspot.com/2011/10/upload-file-using-in-struts-2.html

提交回复
热议问题