Upload CSV Files doesn't work fine with Struts2

524 views Asked by At

I have problem when I'm uploading a csv file by web page jsp. I can upload many files with my Struts2 application. I'm using Struts 2.5.20 and I can upload all Mime types in "allowedTypes" except "text/csv".

    <action name="uploadDocuments" class="UploadDocumentsAction" method="uploadDocuments">
        
        <interceptor-ref name="fileUpload">
            <param name="maximumSize">5242880</param>
            <param name="allowedTypes">image/jpeg,
                image/jpeg2000,
                image/png,
                image/gif,
                image/bmp,
                image/tiff,
                image/apng,
                text/plain,
                text/csv,
                application/pdf,
                application/msword, 
                application/vnd.openxmlformats-officedocument.wordprocessingml.document</param>
        </interceptor-ref> 
        <interceptor-ref name="defaultStack"></interceptor-ref>
          
        <result name="success" type="stream">
            <param name="contentType">text/html</param>  
            <param name="inputName">stream</param>                     
        </result>
    </action>

With Jquery Ajax I invoke action and if "success" show "File Upload Success", otherwise alert "check the extensions of the allowed file types..."

When I try to upload a Csv file I have alert message. I don't understand because only csv File doesn't work, all other files in "allowedTypes" work fine.

I put breakonpoint in my Action, If I try csv file doesn't pass in Java code, when I select other format files it passes.

Thanks

0

There are 0 answers