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

时间:2016-03-10 06:19:12

标签: jsf jsf-2 facelets xml-namespaces

我目前正在使用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.  

以下是 template.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>

我的edit.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库..

1 个答案:

答案 0 :(得分:-3)

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

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