使用JSF 2.2,Jboss 7.运行时只需继续“标记库支持命名空间:http://java.sun.com/jsf/html,但没有为name:outputtext定义标记”这个错误..任何人帮我解决这个问题。
下面是xhtml文件。错误在“”这一行。
的index.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
template="template/ui.xhtml">
<ui:define name="body">
<h3>Welcome to JSF Lab</h3>
<h4>Pure JSF</h4>
<p>
<!-- Shows the error or success message -->
<h:outputtext value="#{fileUploadMBean.message}"
rendered="#{!empty fileUploadMBean.message}">
</h:outputtext>
<!-- notice the enctype for file upload -->
<h:form prependid="false" enctype="multipart/form-data">
<h:panelgrid>
<!-- input for files -->
<h:inputfile value="#{fileUploadMBean.file1}"></h:inputfile>
<h:inputfile value="#{fileUploadMBean.file2}"/>
<!-- action which is responsible for uploading file(s) -->
<h:commandbutton action="#{fileUploadMBean.uploadFile()}" value="Upload" />
</h:panelgrid>
</h:form>
</p>
</ui:define>
</ui:composition>
这是上面xml文件的bean文件..这个
FileUploadMBean.java
@ManagedBean
@ViewScoped
public class FileUploadMBean implements Serializable {
private static final long serialVersionUID = 1L;
private Part file1;
private Part file2;
private String message;
public Part getFile1() {
return file1;
}
public void setFile1(Part file1) {
this.file1 = file1;
}
public Part getFile2() {
return file2;
}
public void setFile2(Part file2) {
this.file2 = file2;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String uploadFile() throws IOException {
//upload code
}
}
我知道库和版本都没问题。因为当我用另一个xhtml运行另一个bean类时它的工作正常,同样的h:outputtext没有显示错误..问题我不明白。它会是任何配置问题或其他什么。
答案 0 :(得分:0)
正如Balus C在评论中所说的错字错误
使用
<h:outputText> </h:outputText>
<h:panelGrid></h:panelGrid>
<h:commandButton action="#{fileUploadMBean.uploadFile}" value="Upload" ></h:commandButton>