Invisible comments in jsf 2.0? [duplicate]

2019-04-18 09:07发布

This question already has an answer here:

is it possible to embed comments in my .xhtml-files that are only displayed in the source and not the rendered result? I want to include author, date,... in the files but they should not be visible to the enduser in the generated output. If I use the standard comment-tags <!-- --> the browser displays them.

3条回答
别忘想泡老子
2楼-- · 2019-04-18 09:40

Wrong, the right way is:

<context-param>
    <param-name>facelets.SKIP_COMMENTS</param-name>  
    <param-value>true</param-value>  

This work for me, javax.faces.FACELETS_SKIP_COMMENTS no!

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-04-18 09:44

Add the following into your web.xml:

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

This way Facelets will skip the comments while parsing the view xhtml template.

查看更多
Lonely孤独者°
4楼-- · 2019-04-18 09:48

Invisible comments in JSF is a drawback, specially for beginers. I agree with answer of Mr Minchev. Anyway, I provide an alternative way to comment content in JSF consisting of using ui:remove

<ui:remove> This is a comment </ui:remove>

The UI Remove tag is used to specify tags or blocks of content that should be removed from your page by the Facelets view handler at compile time. This tag has no attributes. You can use this tag to indicate that a particular tag should be removed from the rendered page.

It's useful to remove content which is required during design time, but not during run time, such as comments, some stubbed content (e.g. "lorem ipsum") which aids in filling up the page content to fit the layout in visual designers such as Dreamweaver, etc.

See: Practical implications of Facelets ui:remove tag

Note that the Facelets compilation process is much faster than the JSP compilation process because no Java bytecode is actually generated and compiled behind the scenes when you first visit your page. The UI Remove tag is used to specify tags or blocks of content that should be removed from your page by the Facelets view handler at compile time. This tag has no attributes.

Examples of both comment options

查看更多
登录 后发表回答