让JSPX避免创建自闭标签(< div>< / div>!=< div />) [英] Keep JSPX from creating self closing tags (<div></div> != <div/>)

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

问题描述

 < div class =magic>< / div> ; 

进入:

 < div class =magic/> 

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

  def m = html =〜/<(\ w +)[^>] *?>< \ /(\ 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避免创建自闭标签(&lt; div&gt;&lt; / div&gt;!=&lt; div /&gt;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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