0
필자는 정확한 JSF/CDI 프로젝트에서 FileUpload 기능을 구현하려고한다. 올바른 종속성 (thinks)과 프라임 쇼케이스에서 찾은 코드와 동일하다.방법을 찾을 수 없습니까? 이것은 말이 안된다.
하지만 어떤 이유로 FileUpload 이벤트가 ManagedBean의 수신기를 찾지 못합니다.
나는 내가 여기에서 놓친 것을 볼 수 있기를 바란다. 나는 이미 많은 시간 동안 코드를 검사했으나 문제를 일으킬 수있는 것을 찾지 못했다.
내 XHTML 페이지 :
<html>
<h:head>
</h:head>
<body>
<h:form>
<p:fileUpload fileUploadListener="#{file.uploadHandler()}"
mode="advanced" dragDropSupport="false" update="messages"
sizeLimit="100000" fileLimit="3"
allowTypes="/(\.|\/)(gif|jpe?g|txt)$/" />
<p:growl id="messages" showDetail="true" />
</h:form>
</body>
</html>
내 ManagedBean은 :
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.event.FileUploadEvent;
@Named
@ViewScoped
public class File implements Serializable {
private static final long serialVersionUID = -6644472075906217176L;
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public void uploadHandler(FileUploadEvent event) {
System.out.println("Nome do Arquivo: " + event.getFile().getFileName());
}
}
내 pom.file :
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.14</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
콘솔 :
15:59:36,935 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-27) /index.xhtml @16,45 fileUploadListener="#{file.uploadHandler()}": Method not found: class timesheet.business.bean.File.uploadHandler(): javax.el.MethodNotFoundException: /index.xhtml @16,45 fileUploadListener="#{file.uploadHandler()}": Method not found: class timesheet.business.bean.File.uploadHandler()
귀하의 메서드는 매개 변수를 사용하지만 EL에 매개 변수를 전달하지 않습니다. – chrylis