我尝试重现本教程http://www.javatutorials.co.in/jsf-2-2-file-upload-example-using-hinputfile/,我遇到了一个大问题:inputFile标签不适用于我。
<h:form id="inputForm" enctype="multipart/form-data">
Upload File
<h:inputFile id="file"
label="file"
value="#{inputBean.part}"
required="true"
requiredMessage="File not selected !!">
</h:inputFile>
<h:message style="color: red" for="file" /><br />
<h:commandButton id="submit"
action="#{inputBean.uploadFile}"
value="upload file" /><br />
<h:outputText value="#{inputBean.statusMessage}"
rendered="#{not empty inputBean.statusMessage}" />
</h:form>
我见过问题Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: inputFile,但在我的pom文件中使用了正确的文件版本(2.2.7> 2.2.4)
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.7</version>
</dependency>
答案 0 :(得分:2)