错误解析/page.xhtml:错误追踪[行:42]被引用,但未声明 [英] Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared

查看:123
本文介绍了错误解析/page.xhtml:错误追踪[行:42]被引用,但未声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的JSF页面中使用不间断空格.我知道,在纯HTML中,我可以为此使用 ,并且效果很好.但是,当我将这些 放在Facelets页面中时,它将出现以下错误:

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:

错误解析/page.xhtml:跟踪错误[行:42]实体"nbsp"已被引用,但未声明.

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?

推荐答案

Facelets是一种基于XML的视图技术. XML仅具有五个预定义实体.  不在其中.它仅在纯HTML或旧版JSP中使用时才有效(请注意:它在JSPX中不起作用,因为它也是基于XML的!).

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

要解决此问题,您需要在包含 实体的XHTML文件的doctype中自己声明实体,

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;

在普通的IDE中,执行查找并替换所有文件"并将每个出现的&nbsp;替换为&#xA0;应该很简单.

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;.

这篇关于错误解析/page.xhtml:错误追踪[行:42]被引用,但未声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆