What is 'eating' my uploadFile before my POST servlet can process it?

后端 未结 1 1884
有刺的猬
有刺的猬 2021-01-24 18:40

I\'m using Infragistics IgniteUI igUpload on my webpage to upload files to our Apache Tomcat server, and while the files are uploaded, I can\'t get access to them in my servlet

1条回答
  •  不思量自难忘°
    2021-01-24 19:26

    If you are using Struts2, you will probably have this setting in web.xml:

    
        struts2
        
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
        
    
    
    
        struts2
        /*
    
    

    Since the url-pattern is /*, it means that every request is intercepted by the StrutsPrepareAndExecuteFilter (usually called Filter Dispatcher, that was also the old filter name, in Struts versions before 2.1.8).

    If you call an action, this is perfect. If you call a servlet, a web-service, or something else, this is problematic, because Struts Filter should run for actions only.

    To exclude a particular url (or a particular pattern) from being intercepted by the filter, you need to use the constant struts.action.excludePattern in struts.xml, as described in

    • Jersey with Struts2

    • How to use Servlet in Struts2

    • Official Apache Documentation: web.xml

    Then put in struts.xml

    
    

    And it should work.


    At this point, I'm curious to know why are you using Struts2 without exploiting the great inbuilt File Upload functionality, that is explained in

    • Need to upload multiple files at once

    and that can work with other upload-oriented frameworks with minor adjustments, like demonstrated in:

    • Upload multiple files in Struts2 with Dropzone.js

    I don't know the plugin you're using, but in your case the first (and probably only) problem I see is the name of the parameter sent out:

    uploadDoc_0__frm_if
    

    should be unnumbered, and it'll still need a mixed CamelCase / Snake_case approach in your variable name.

    0 讨论(0)
提交回复
热议问题