How can I remove HTML comments in my Facelets?

2019-01-08 20:11发布

I would like to remove all HTML comments from my facelets before delivering to end users. Does any standard approach exist?

1条回答
Ridiculous、
2楼-- · 2019-01-08 21:12

There are actually two ways:

  1. To remove ALL comments, add this to web.xml:

    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    

    or when you're still on JSF 1.2 which doesn't use Facelets as default view technology yet:

    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    
  2. To remove specific comments only, use <ui:remove>.

    <ui:remove><!-- This is a HTML comment. --></ui:remove>
    
查看更多
登录 后发表回答