Here we introduce the comments of various codes in JSP. css comment: /* This is the CSS comment * /; js comment: // Here is the JS comment; html comment: < !- - This is a JSP file - ->; Java comment: // Here is the java script ;JSP dynamic tag comment: <%- -Here is the JSP dynamic tag comment- -%>
##Please take a look at the example :
如下为JSP中各种注释的具体体现 <%@ page language="java" contentType="text/html; charset=UTF-8" %> <%@ page session="true" import="java.util.Date,java.text.SimpleDateFormat" pageEncoding="UTF-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>JSP的三种java脚本 java脚本
<% //这里是java小脚本,生成java类时,不做任何翻译。 定义的所有的变量都是局部变量。存在于_jspService方法中 int x = 10; //int z = x/0; System.out.println("x="+x); session.setAttribute("pageName", "index.jsp"); System.out.println(session.getAttribute("pageName")); %>
<% x++; System.out.println("x="+x); %>脚本表达式
x=<%=x+10 %>脚本申明
<%! //在生成的java代码中申明成员变量和成员方法 public void method(){ } String str = "abc"; %> <%-- 这里是JSP注释 --%>
Summary: JSP function: simplify writing html tags, dynamically generate web page content (java code can be written in jsp) demonstration, each element in the jsp file Comments
<%- - Comments in jsp files: will not be translated into .java files - -%> <%- - HTML comments, java code cannot be commented out , however, it still works in html files - -%> <%- - java comments will be translated into .java files intact - -%> <%- - Summary: Use which type of comments you want to see in which type of file - -%>The above is the detailed content of How to comment code on jsp page. For more information, please follow other related articles on the PHP Chinese website!