Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
834 views
in Technique[技术] by (71.8m points)

jsf - Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared

I'd like to use non breaking spaces in my JSF page. I know, in plain HTML I could use   for this and this works fine. However, when I put those   in a Facelets page, then it errors as follows:

Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared.

How is this caused and how can I solve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Facelets is a XML based view technology. XML has only five predefined entities. The   is not among them. It works only when used in plain HTML or in legacy JSP (note: it doesn't work in JSPX as that's also XML based!).

To fix this, you either need to declare the entity yourself in the doctype of the very XHTML file containing the   entity,

<!DOCTYPE html [
    <!ENTITY nbsp "&#160;"> 
]>

or, better, use the (hexa)decimal notation instead:

&#xA0; or &#160;

In an average IDE it should be trivial to perform a "find and replace in all files" and replace every occurrence of &nbsp; by &#xA0;.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...