h:commandButton is not firing action if the h:form has enctype=“multipart/form-data”

后端 未结 2 1210
误落风尘
误落风尘 2021-01-15 12:54

JSF: 1.2

Server: Weblogic

I am trying to implement multiple file upload. As I need to give support for IE7 so I cannot use

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 13:27

    Here,

    for (FileItem item : items) {
        if (!item.isFormField()) {
            files.add(item);
        }
    }
    

    you're ignoring all form fields, such as the button itself. When continuing such a request, JSF will have no clue that a button was been invoked and thus not queue any action at all.

    You need to add an else to collect all form fields in a Map and wrap the request with a HttpServletRequestWrapper which delegates to that map on all getParameterXxx() calls and finally continue the filter chain with the wrapped request. This way JSF will find out that the button was invoked and then queue to the proper action.

提交回复
热议问题