Home > Java > Java Tutorial > body text

How to comment code on jsp page

(*-*)浩
Release: 2019-06-04 16:15:54
Original
5975 people have browsed it

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- -%>

How to comment code on jsp page

##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注释 --%>

当前服务器系统时间

<% Date date = new Date(); SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); String dateStr = format.format(date); %> <%=dateStr %>

JSTL

session中区数据

<%=session.getAttribute("sname") %>
Copy after login

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!

Related labels:
jsp
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!