JSF display HTML comment

末鹿安然 提交于 2020-01-22 13:48:29

问题


I am using JSF 2.0 and have defined property javax.faces.FACELETS_SKIP_COMMENTS to skip comments in JSF code because there is a lot of other code, deveploping comments etc. But I need to print some HTML comments into client's browser eg. for defining alternative conditioned stylesheet for other browsers.

Please is there any way how to do it? Because all my attempts failed.


回答1:


Use <ui:remove> to remove comments instead of the context parameter.




回答2:


This is crude but it does work (under JSF 1.2 anyway not tested in 2)

<h:outputText value="&lt;!--" escape="false" /> My comment <h:outputText value="--&gt;" escape="false" />



回答3:


Maybe you could use f:verbatim:

<f:verbatim>&lt;!--[if lt IE 7]&gt;
    Something just for lower than IE7
&lt;![endif]--&gt;</f:verbatim>



回答4:


Based on @Juan's and @reevesy's ideas is this one:

<f:verbatim>&lt;!--
    This is a happy HTML comment :)
--&gt;</f:verbatim>

Which will render:

<!--
    This is a happy HTML comment :)
-->


来源:https://stackoverflow.com/questions/4238767/jsf-display-html-comment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!