如何删除JSF输出中的空格? [英] How to remove white spaces in JSF output?

查看:139
本文介绍了如何删除JSF输出中的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以配置JSF 2.0以删除XHTML标记之间不必要的空格?

Is it possible to configure JSF 2.0 to remove unnecessary white spaces between XHTML tags?

推荐答案

否。 Facelets无法将不必要的空格与必要的空格区分开来。为此,它需要确定单独的HTML标记,解析CSS和JS文件以获取真正不必要的任何证据。如果是HTML < pre> < textarea> 标记,则CSS white-space:pre 属性和JS element.style.whiteSpace ='pre'代码,空格很重要。

No. Facelets cannot distinguish unnecessary whitespace from necessary whitespace. For that it would need to determine individual HTML tags, parse CSS and JS files for any evidence that it is really unnecessary. In case of the HTML <pre> and <textarea> tags, the CSS white-space:pre property and JS element.style.whiteSpace='pre' code, the whitespace is namely significant.

检查可靠性太昂贵和复杂。如果实际关注的是网络带宽,那么只需在服务器级别打开gzip压缩。如何做到这一点取决于所使用的服务器,但在Tomcat上,例如它就像在< Connector>中添加 compression =on一样简单。 /conf/server.xml 中的元素。

It's simply too expensive and complicated to check that reliably. If your actual concern is network bandwidth, then just turn on gzip compression at server level. How to do that depends on the server used, but on Tomcat for example it's as easy as adding compression="on" to the <Connector> element in /conf/server.xml.

但是可以创建一个过滤器,它取代响应编写器来修剪空白。您可以在此处找到此类过滤器的示例。它只是不考虑CSS / JS。

It is however possible to create a Filter which replaces the response writer to trim the whitespace. You can find here an example of such a filter. It only doesn't take CSS/JS into account.

这篇关于如何删除JSF输出中的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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