结论:jsp注释不会被传输到浏览器端。
创建
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP注释</title>
</head>
<body>
<!-- 这个是HTML注释 -->
<%--这个是JSP注释 --%>
</body>
</html>
访问该jsp
http://localhost:8080/chapter06/example02.jsp
jsp被翻译成java的核心源代码如下:
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n");
out.write("<title>JSP注释</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("\t<!-- 这个是HTML注释 -->\r\n");
out.write("\t");
out.write("\r\n");
out.write("</body>\r\n");
out.write("</html>");