SVG之后,JSF吞下了关闭标签 [英] JSF swallows closing tag after SVG

查看:131
本文介绍了SVG之后,JSF吞下了关闭标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在<ul>中使用了两个<svg>元素.

I'm using two <svg> elements inside a <ul>.

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"      
    xmlns:h="http://java.sun.com/jsf/html">

...
<ul>
    <li>
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" >...</svg>
    </li>
    <li>
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" >...</svg>
    </li>
</ul>
...
</html>

JSF在渲染HTML时吞下了第一个结尾</li>.

JSF is swallowing the first closing </li> when it's rendering the HTML.

这是错误还是我的xhtml无效?

Is this a bug or is my xhtml invalid?

我正在使用Mojarra 2.1.7.

I'm using Mojarra 2.1.7.

更新:如@BalusC所建议,我将此报告为莫哈拉人(Mojarra Guys).

Update: As @BalusC suggested I reported this to the Mojarra Guys.

更新2:使用Mojarra 2.1.26 2.2.3

Update 2: Fixed with Mojarra 2.1.26 and 2.2.3

推荐答案

我可以在2.1.24中重现它.我不确定这是否是Facelets的SAX解析器中的错误,但确实看起来很像它在嵌套名称空间中感到困惑.您正在使用<svg xmlns>声明一个新的默认XML名称空间,该名称空间似乎已经覆盖了HTML标记的<html xmlns>一个.我建议报告此问题给Mojarra伙计们.

I can reproduce it in 2.1.24. I'm not sure if this is a bug in Facelets' SAX parser but it indeed look much like that it got confused in nested namespaces. You're with <svg xmlns> declaring a new default XML namespace which has seemingly overriden the <html xmlns> one for HTML tags. I recommend to report this issue to Mojarra guys.

无论如何,在Facelets中使用SVG的正确方法是将整个<svg>内容拆分为自己的.svg文件,并通过<ui:include>包含它.

In any case, the right way of using SVG in Facelets is to split off the whole <svg> content into its own .svg file and include it via <ui:include>.

<ul>
    <li>
        <ui:include src="/resources/svg/one.svg" />
    </li>
    <li>
        <ui:include src="/resources/svg/two.svg" />
    </li>
</ul>

这样,命名空间就可以正常工作.另一个好处是,您的SVG可以立即重用.

This way the namespacing works fine. Additional benefit is, your SVGs are this way instantly reusable.

这篇关于SVG之后,JSF吞下了关闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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