jsf 2.0 中看不见的注释?

发布于 2024-09-14 12:04:33 字数 135 浏览 5 评论 0 原文

是否可以在我的 .xhtml 文件中嵌入注释,这些注释仅显示在源代码中,而不显示在渲染结果中? 我想在文件中包含作者、日期...,但最终用户在生成的输出中不应该看到它们。如果我使用标准注释标签 浏览器会显示它们。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

任谁 2024-09-21 12:04:33

将以下内容添加到您的 web.xml 中:

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

这样,Facelets 将在解析视图 xhtml 模板时跳过注释。

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.

岁月苍老的讽刺 2024-09-21 12:04:33

JSF 中的不可见注释是一个缺点,特别是对于初学者而言。我同意明切夫先生的回答。无论如何,我提供了一种在 JSF 中注释内容的替代方法,其中包括使用 ui:remove

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

UI 删除标记用于指定应由 Facelets 视图处理程序从页面中删除的标记或内容块在编译时。该标签没有属性。您可以使用此标记来指示应从呈现的页面中删除特定标记。

删除设计时期间所需的内容很有用,但在运行期间则不然时间,例如评论、一些存根内容(例如“lorem ipsum”),这些内容有助于填充页面内容以适合视觉设计器(例如 Dreamweaver)等中的布局。

请参阅:Facelets ui:remove tag 的实际影响

请注意,Facelets 编译过程比 JSP 编译快得多 因为当您第一次访问页面时,实际上并没有在幕后生成和编译 Java 字节码。 UI 删除标记用于指定 Facelets 视图处理程序在编译时应从页面中删除的标记或内容块。该标签没有属性。

两个评论选项的示例


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

始终不够爱げ你 2024-09-21 12:04:33

错误的是,正确的做法是:

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

这对我有用,javax.faces.FACELETS_SKIP_COMMENTS 不!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文