Javascript JSF facelet页面没有';带有'&';性格
在JSF facelet页面(.xhtml)中,我有以下javascript代码Javascript JSF facelet页面没有';带有'&';性格,javascript,jsf,facelets,Javascript,Jsf,Facelets,在JSF facelet页面(.xhtml)中,我有以下javascript代码 <script type="text/javascript"> function navigateToDetail() { var id = document.getElementById("idElemento").value; alert(id); var isPratica = document.getElem
<script type="text/javascript">
function navigateToDetail() {
var id = document.getElementById("idElemento").value;
alert(id);
var isPratica = document.getElementById("isPratica").value;
alert(isPratica);
var box = "#{boxCtrl.idBox}";
alert(box);
if (isPratica==true)
window.location = "DettaglioRichiesta.xhtml?id=" + id + "&box=" + box;
else
window.location = "../Richieste/DettaglioRichiesta.xhtml?id=" + id + "&box=" + box;
}
</script>
我可以避免这种行为吗?Facelets是一种基于XML的视图技术。
和
是一个。它被解释为XML实体的开始,如
, 代码>,等等。因此,它正在查找结束字符代码>,但找不到,因此抛出此错误
要在XML文档中按字面意思表示&
,需要使用&代码>而不是&
window.location=“DettaglioRichiesta.xhtml?id=“+id+”&;box=“+box;
您还可以将JS代码放在自己的.JS
文件中,该文件由
包含,这样您就不需要在JS代码中处理XML特殊字符
谢谢,我知道外部js文件,但我很想在“页面”中解决它。谢谢你的解决方案
Error Parsing /Box/ListaRichieste.xhtml: Error Traced[line: 20] The reference to entity "box" must end with the ';' delimiter