JavaEE 此页面调用 XML 命名空间,但该命名空间不存在标记库



我目前正在用EJB 3.1,JSF 2.0,mySQL,Netbeans进行Java-EE项目。

我在.xhtml中创建了模板,但是当我编译时,我收到此警告:

Warning: This page calls for XML namespace declared with prefix div but no taglibrary exists for that namespace.  
Warning: This page calls for XML namespace declared with prefix h3 but no taglibrary exists for that namespace.  
Warning: This page calls for XML namespace declared with prefix div but no taglibrary exists for that namespace.  
Warning: This page calls for XML namespace declared with prefix p but no taglibrary exists for that namespace.  

这是我的模板代码.xhtml(你可以看到我已经包含了需要的东西):

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
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">
<h:head>
  <title><ui:insert name="title">Default title</ui:insert></title>
  <h:outputStylesheet name="css/style.css" />
      <ui:insert name="javascript"></ui:insert>
</h:head>
<h:body>
    <div id="header">
        <ui:insert name="header">       
            <ui:include src="header.xhtml"/>
        </ui:insert>
    </div>
    <div id="metadata">
        <ui:insert name="metadata"/>
    </div>
    <div id="content">
      <ui:insert name="content" />
    </div>
    <div id="footer">
      <ui:insert name="footer">     
            <ui:include src="footer.xhtml"/>
      </ui:insert>
    </div>
</h:body>

我的编辑.xhtml :

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/template/template.xhtml">
<ui:define name="metadata">
    <f:metadata>
        <f:viewParam name="trackId" value="#{trackBean.track.trackId}" />
        <f:event listener="#{trackBean.findTrack}" type="preRenderView"></f:event>
    </f:metadata>
</ui:define>
<ui:define name="content">
    <h:messages globalOnly="true" errorStyle="color: red" infoStyle="color: green" layout="table" />
    <h1>Edit Track</h1>
    <h:form>
        <h:panelGrid styleClass="editTable" columns="2" cellpadding="4" cellspacing="0">                                   
            <h:outputLabel value="Track Id" id="trackId"/>
            <h:outputText value="#{trackBean.track.trackId}"/>
                    <h:outputLabel value="User Id" id="userId"/>            
            <h:outputText value="#{trackBean.track.user.userId}"/>
            <h:outputLabel value="Longitude"  id="trackLongitude"/>
            <h:inputText value="#{trackBean.track.trackLongitude}" />
            <h:outputLabel value="Latitude" id="trackLatitude" />
            <h:inputText value="#{trackBean.track.trackLatitude}" />
            <h:outputText value="Speed" id="trackSpeed"/>
            <h:inputText value="#{trackBean.track.trackSpeed}" />
                    <h:outputLabel for="date">Date:</h:outputLabel>
                    <h:inputText id="date" value="#{trackBean.track.trackDate}" 
                    size="20" required="true" label="Date" >
                        <f:convertDateTime pattern="d-M-yyyy" />
                    </h:inputText>
            <h:commandButton action="#{trackBean.updateTrack}" value="Edit Track" />
        </h:panelGrid>
        <h:panelGrid styleClass="navTable">
            <h:link outcome="view" value="View Details" includeViewParams="true">
                <f:param name="trackId" value="#{trackBean.track.trackId}"></f:param>
            </h:link>
            <h:link outcome="index" value="List Tracks" />
        </h:panelGrid>
    </h:form>
</ui:define>

我错过了什么吗?我在我的项目中包含了JSF库。

你有正确的 maven 依赖项吗?如果它是一个非 maven 项目,请将其转换为 maven,它将为您解决所有问题。稍后我将发布正确的依赖项。如果其他人不是第一个:-)

JPA EJB CDI JMS (java ee) 使用 Maven 或类似内容的最佳实践