首页 > 解决方案 > 警告:此页面调用以前缀 t 声明的 XML 命名空间 http://xmlns.jcp.org/jsf/component 但该命名空间不存在标记库

问题描述

我正在使用JSF 2.2并且我想创建一个custom componentusing 注释。但是,访问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>

标签: jsfjsf-2.2custom-component

解决方案


推荐阅读