防止 JSPX 创建自关闭标签 (<div></div>!= <div/>) [英] Keep JSPX from creating self closing tags (&lt;div&gt;&lt;/div&gt; != &lt;div/&gt;)

查看:16
本文介绍了防止 JSPX 创建自关闭标签 (<div></div>!= <div/>)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSPX 有个可爱的翻面效果:

进入:

对于许多浏览器,即使它是有效的 XHTML,这也会导致布局混乱和混乱.因此,我不得不使用 groovy 脚本通过以下正则表达式查找所有可能的错误 HTML:

def m = html =~/<(w+)[^>]*?>/def bad = m.findAll { it[1] == it[2] };

有没有办法让 JSPX XML 处理器不自行关闭标签?

解决方案

AFAIK,对此没有优雅的解决方案(阅读:可在容器级别配置).检查GlassFish v3 上的jspx 脚本元素"以了解可能的解决方法.

JSPX has the lovely side effect of turning:

<div class="magic"></div>

Into:

<div class="magic" />

For many browsers this causes pandemonium and mayhem with layout even though it is valid XHTML. Consequently I have resorted to using a groovy script to find all possible bad HTML with the following regex:

def m = html =~ /<(w+)[^>]*?></(w+)>/
def bad = m.findAll { it[1] == it[2]  };

Is there way to have the JSPX XML processor not to self close tags?

解决方案

AFAIK, there is no elegant solution to this (read: configurable on container level). Check "jspx script element on GlassFish v3" for possible workarounds.

这篇关于防止 JSPX 创建自关闭标签 (<div></div>!= <div/>)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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