警告:此页面需要使用前缀t声明的XML名称空间http://xmlns.jcp.org/jsf/component,但该名称空间不存在标记库

时间:2019-05-21 10:35:32

标签: jsf jsf-2.2 custom-component

我正在使用JSF 2.2,并且我想使用注释创建一个custom component。但是,访问 welcome.xhtml 时,出现以下错误:

Warning: This page calls for XML namespace http://xmlns.jcp.org/jsf/component declared with prefix t but no taglibrary exists for that namespace.

问题可能出在以下事实:我无法在@FacesComponent批注中使用“ createTag”

@FacesComponent(value="components.HelloWorldComponent")
public class HelloWorldComponent extends UIComponentBase{

    @Override
    public String getFamily() {
        // TODO Auto-generated method stub
        return "hello.world.component";
    }

    @Override
    public void encodeBegin(FacesContext context) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        writer.write("Hello everyone");
    }

}

这是我的welcome.xhtml

<!DOCTYPE HTML>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:c="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
     xmlns:t="http://xmlns.jcp.org/jsf/component"
   >
    <h:head>
        <title>Hello World - Input Form1</title>
    </h:head>
    <h:body>
        <h:form>
            <h:inputText id="name" value="#{helloBean.name}"
                p:placeholder="What's your name?" />
            <h:commandButton value="Submit" action="hello" />
        </h:form>
         <t:helloWorldComponent/>
          <h:outputText value="TEST"></h:outputText>
    </h:body>
</html>

0 个答案:

没有答案