javax.el.MethodNotFoundException:fileUploadListener =“#{uploadFileBean.handleFileUpload}”

时间:2013-11-28 12:38:38

标签: file-upload jsf-2 primefaces

我有这个页面:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:ice="http://www.icesoft.com/icefaces/component"
    xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>
<h:body>
    <h1>Hello World PrimeFaces</h1>

    <h:form enctype="multipart/form-data">
        <p:fileUpload
            mode="advanced"
            fileUploadListener="#{uploadFileBean.handleFileUpload}"
            allowTypes="/(\.|\/)(gif|jpg|jpeg|gif|png|PNG|GIF|JPG|JPEG)$/"
            auto="true" />
    </h:form>


</h:body>
</html>

和这个bean:

package com.gravitant.cloud.common.jsf.core.beans;

import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import lombok.Getter;
import lombok.Setter;

import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;

@ManagedBean
@SessionScoped
public class UploadFileBean {

    @Getter
    @Setter
    private UploadedFile file;

    public void handleFileUpload(FileUploadEvent event) {
        System.out.println("---uploaded file: " + event.getFile().getFileName());
        FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}

选择要上传的特定图片后,我会收到:

Caused by: javax.el.MethodNotFoundException: //C:/dev/gravitant/git-repositories/cloudMatrix-team/cloudmatrix-team/CloudMatrixWeb/CloudMatrix-Web/USERAPP/WebContent/userapp-main.jsf @22,18 fileUploadListener="#{uploadFileBean.handleFileUpload}": Method not found: com.gravitant.cloud.common.jsf.core.beans.UploadFileBean@39d02150.handleFileUpload(org.primefaces.event.FileUploadEvent)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109) [jsf-impl-2.1.6.jar:2.1.6-SNAPSHOT]
at org.primefaces.component.fileupload.FileUpload.broadcast(FileUpload.java:280) [primefaces-3.5.jar:]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:759) [jsf-api-2.1.6.jar:2.1.6-SNAPSHOT]

但我确信我正确地输入了该方法的名称。

我有什么想念吗?

我正在使用jsf 2.1.6,jboss 7,Primefaces(使用3.4和3.5进行测试)

0 个答案:

没有答案