【问题标题】:JavaEE This page calls for XML namespace but no taglibrary exists for that namespace [duplicate]JavaEE 此页面调用 XML 命名空间,但该命名空间不存在标记库 [重复]
【发布时间】:2016-03-10 06:19:12
【问题描述】:

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

【问题讨论】:

  • 我的edit.xhtml代码中已经有&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"&gt;,所以它不重复...

标签: jsf jsf-2 facelets xml-namespaces


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 2012-10-07
    相关资源
    最近更新 更多