1、HTML文档中的注释:
在HTML网页文档中使用 “ <!-- 所注释内容 -->” 这种格式加入注释,注释的内容将被浏览器忽略。可以使用注释来解释文档中的某些部分的作用和功能,也可以使用注释的形式在网页的文档中插入制作者的姓名、地址和电话号码等个人信息,此外,还可以使用注释来暂时屏蔽某些HTML语句,让浏览器暂时不要理会这些语句,等到需要时,只需简单地取消注释标签,这些HTML语句又可以发挥作用了。
注意,“<!-- …… -->” 中不能嵌套有“<!-- …… -->” ,因为第一个 “<!--“ 会以在它后面第一次出现的 ”-->“ 作为与它配对的结束注释符。
2、Velocity ——VTL模板中的注释
注释允许在模板中包含描述文字,而这些文字不会被放置到模板引擎的输出中。注释是一种有效的提醒自己和向别人解释你的VTL语句要做什么事情的方法。你也可以把注释用来做其他你认为有用的用途。
(1):单行注释:## 单行注释内容
## This is a single line comment。
(2):#* 多行注释内容 *#
一个单行的注释以##开始,直到行尾才结束。如果你要写很多行的注释,那么不用使用多各单行注释,VTL还提供了多行注释。多行注释以#*开始,以*#结束。下面是一个多行注释的例子。
This is text that is outside the multi-line comment.
Online visitors can see it.
#*
Thus begins a multi-line comment. Online visitors won't
see this text because the Velocity Templating Engine will
ignore it.
*#
Here is text outside the multi-line comment; it is visible.
在使用Velocity引擎解析上面的模板时,输出的结果是:
This is text that is outside the multi-line comment.
Online visitors can see it.
Here is text outside the multi-line comment; it is visible.
可以看到,多行注释内的内容是不会输出的。
(3):
在VTL中还有第三种注释:VTL注释块。VTL注释块用来保存如文档的作者、版本号等信息。例如:
#**
This is a VTL comment block and
may be used to store such information
as the document author and versioning
information:
@author
@version 5
*#
3、properties文件写注释
用#开头
4、CSS文件中的注释
/* */
/* 要注释的内容 */