2011-12-26 56 views
12

我遇到了一個JSF頁面的問題。這是源代碼:警告:此頁面調用使用前綴[HTML元素名稱]聲明的XML名稱空間,但該名稱空間不存在taglibrary

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns:h="http://java.sun.com/jsf/html"> 
    <head> 
     <title>Login</title> 
     <link rel="stylesheet" type="text/css" href="resources/css/style.css" /> 
     <script src="resources/js/cufon-yui.js" type="text/javascript"></script> 
     <script src="resources/js/ChunkFive_400.font.js" type="text/javascript"></script> 
     <script type="text/javascript"> 
      Cufon.replace('h1',{ textShadow: '1px 1px #fff'}); 
      Cufon.replace('h2',{ textShadow: '1px 1px #fff'}); 
      Cufon.replace('h3',{ textShadow: '0px 1px #000'}); 
      Cufon.replace('.back'); 
     </script> 
    </head> 
    <body> 
     <div class="wrapper"> 
      <div class="content"> 
       <div id="form_wrapper" class="form_wrapper">      
        <h:form class="login active"> 
         <h3><img style="text-align:center" src="resources/images/title.png"/></h3> 
         <div> 
          <label>Username:</label> 
          <h:inputText value="#{loginController.user}" autocomplete="off"/>       
         </div> 
         <div> 
          <label>Password:</label> 
          <h:inputSecret value="#{loginController.password}" autocomplete="off"/>       
         </div> 
         <div class="bottom">  
                 <h:commandButton label="Login" value="Login" action="#{loginController.userCompare}"/> 
          <div class="clear"></div> 
         </div> 
        </h:form>     
       </div> 

          <div id="error_message" style="text-align:center; padding-top:50px; font-style:normal; font-size:20px"> 
           #{loginController.error_Database} 
           #{loginController.error_Message} 
          </div> 

      </div>   
     </div> 
    </body> 
</html> 

當我加載出現此錯誤信息的頁面在頁面底部:

Warning: This page calls for XML namespace declared with prefix body but no taglibrary exists for that namespace. 
Warning: This page calls for XML namespace declared with prefix title but no taglibrary exists for that namespace. 
Warning: This page calls for XML namespace declared with prefix link but no taglibrary exists for that namespace. 
Warning: This page calls for XML namespace declared with prefix img 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 div 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 div 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 div 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 div but no taglibrary exists for that namespace. 

你能給我知道如何解決這個問題呢?我想這個問題出現在JSF標籤中。

回答

27

嘗試用這個命名空間聲明

<?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 xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:h="http://java.sun.com/jsf/html"> 
+0

我使用的是xmlns:h =「ht tp://xmlns.jcp.org/jsf/html「,我得到了上述錯誤。當我將其更改爲xmlns:h =「http://java.sun.com/jsf/html」它工作!瓦剌! – dirai 2017-10-04 17:09:00

+0

「xmlns.jcp.org/*」命名空間是較新的,Java EE 7+ URI,也參見https://stackoverflow.com/questions/7593603/jstl-xmlns-namespace-differences-between-jsf-1-2 -and-jsf-2-x – Kawu 2017-12-20 17:22:19

8

只需添加這

的xmlns =「http://www.w3.org/1999/xhtml

它不是W3C只有W3,它的工作很好,

+0

嗨,我已經有xmlns =「http://www.w3.org/1999/xhtml」和xmlns:h =「http://java.sun.com/jsf/html 「但我仍然得到一些這種錯誤類型。 – 2017-11-26 07:29:13

相關問題