7

I'm preparing for an interview so while reading some questions I found that the "JSP comment is called hide comment whereas html comment is called output comment". And the answer says that if we try to view source in JSP, the comments will not be shown whereas in HTML, it will be shown.

But I'm able to see the comment in the view source section. Can anybody clear this doubt?

Thanks in advance.

4

3 回答 3

19

JSP 中允许使用两种类型的注释。这些是隐藏和输出评论。隐藏的注释不会出现在 html 的生成输出中,而输出注释会出现在生成的输出中。

隐藏评论示例:

<%-- This is hidden comment --%>

输出注释示例:

<!-- This is output comment -->
于 2013-04-24T05:41:33.517 回答
4

好吧,从技术上讲,如果您使用典型的 JSP 注释,例如

<%-- This is a comment --%> 

, 并做一个 veiw 源代码, 你不会在客户端看到它, 如果你做一个 HTML 样式的评论

<!-- This is a comment --> 

,您可以查看查看源代码并在客户端查看。不用说,您也可以像普通的 java 风格一样在 jsp 标签内进行评论。希望能帮助到你 。

于 2013-04-24T05:47:55.073 回答
2

Html 注释不会阻止 jsp 评估值

<!-- <%! int x = 0; %> -->

这一行将声明 x 变量。

于 2015-04-27T15:05:03.123 回答