2011-12-26 16 views
12

Tôi gặp sự cố với một trang JSF. Đây là mã nguồn:Cảnh báo: Trang này gọi cho không gian tên XML được khai báo bằng tiền tố [tên phần tử HTML] nhưng không có thư viện thẻ nào tồn tại cho không gian tên đó

<!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> 

Khi tôi tải trang thông báo lỗi này xuất hiện ở phía dưới trong trang:

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. 

Bạn có thể cho tôi ý tưởng làm thế nào để khắc phục vấn đề? Tôi cho rằng vấn đề nằm trong các thẻ JSF.

Trả lời

27

Hãy thử với khai namespace này

<?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

Tôi đã sử dụng xmlns: h = "ht tp: //xmlns.jcp.org/jsf/html "và tôi đã gặp lỗi ở trên. Khi tôi thay đổi nó thành xmlns: h = "http://java.sun.com/jsf/html" nó đã hoạt động! Wala! – dirai

+0

"xmlns.jcp.org/*" các không gian tên là các URI Java 7+ mới hơn, cũng xem https://stackoverflow.com/questions/7593603/jstl-xmlns-namespace-differences-between-jsf-1-2 -and-jsf-2-x – Kawu

8

chỉ cần thêm này

xmlns = "http://www.w3.org/1999/xhtml

nó không phải W3C chỉ W3, nó hoạt động tốt,

+0

Xin chào, tôi đã có xmlns = "http://www.w3.org/1999/xhtml" và xmlns: h = "http://java.sun.com/jsf/html "nhưng tôi vẫn nhận được một số loại lỗi này. –

Các vấn đề liên quan