• JSP学习笔记(一)


    注释:

    1.单行注释<!-- -->或者//

     1 <%@ page language="java" import="java.util.*" contentType="text/html; utf-8""%>
     2 
     3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     4 <html>
     5   <head>
     6     <base href="<%=basePath%>">
     7     
     8     <title>My JSP 'HelloWorld.jsp' starting page</title>
     9     
    10     <meta http-equiv="pragma" content="no-cache">
    11     <meta http-equiv="cache-control" content="no-cache">
    12     <meta http-equiv="expires" content="0">    
    13     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    14     <meta http-equiv="description" content="This is my page">
    15     <!--
    16     <link rel="stylesheet" type="text/css" href="styles.css">
    17     -->
    18     <title>
    19         Hello,World
    20     </title>
    21   </head>
    22   
    23   <body>
    24   <!-- 打印Hello World -->
    25      <%
    26          out.print("Hello,world!");
    27       %>
    28   </body>
    29 </html>

    2.多行注释<% %>

     1 <%@ page language="java" import="java.util.*" contentType="text/html; utf-8""%>
     2 
     3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     4 <html>
     5   <head>
     6     <base href="<%=basePath%>">
     7     
     8     <title>My JSP 'HelloWorld.jsp' starting page</title>
     9     
    10     <meta http-equiv="pragma" content="no-cache">
    11     <meta http-equiv="cache-control" content="no-cache">
    12     <meta http-equiv="expires" content="0">    
    13     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    14     <meta http-equiv="description" content="This is my page">
    15     <!--
    16     <link rel="stylesheet" type="text/css" href="styles.css">
    17     -->
    18     <title>
    19         Hello,World
    20     </title>
    21   </head>
    22   
    23   <body>
    24   <%-- 
    25           打印
    26           Hello,world!
    27   --%>
    28      <%
    29          out.print("Hello,world!");
    30       %>
    31   </body>
    32 </html>

    JSP脚本元素

    1.JSP声明<%!  %>

    2.JSP表达式<%=   %>

    3.JSP Scriptlets<%   %>

     1 <%@ page language="java" import="java.util.*" contentType="text/html; utf-8"%>
     2 
     3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     4 <html>
     5   <head>
     6     
     7     <title>My JSP 'HelloWorld.jsp' starting page</title>
     8     
     9     <meta http-equiv="pragma" content="no-cache">
    10     <meta http-equiv="cache-control" content="no-cache">
    11     <meta http-equiv="expires" content="0">    
    12     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    13     <meta http-equiv="description" content="This is my page">
    14     <!--
    15     <link rel="stylesheet" type="text/css" href="styles.css">
    16     -->
    17     <title>
    18         JSP脚本元素
    19     </title>
    20   </head>
    21   
    22   <body>
    23     <%! 
    24         int num1=1;
    25         int num2=2;    
    26         int num3;
    27         int add(int num1,int num2)
    28         {
    29             return num1+num2;
    30         }
    31     %>
    32     <%
    33         num3=num1+num2;
    34     %>
    35      num1+num2=<%=add(num1,num2) %>
    36      <br>
    37      num3=<% out.println(num3);%>
    38   </body>
    39 </html>
  • 相关阅读:
    【Spark学习笔记】第一章 Windows10(64位)主机上搭建基于IntelliJ IDEA的spark+scala开发环境
    【Oracle数据库相关】Oracle数据库在CentOS6.5环境下的安装以及相关操作
    【SNMP】Linux系统下安装net-snmp
    【SNMP】SNMP概述
    【转】 memwatch使用说明书
    [转]GCC参数详解
    【Linux C中文函数手册】 字符串转换函数
    【Linux C中文函数手册】文件内容控制函数
    【Linux C中文函数手册】之 目录操作函数
    [心智历练]---高效、静心、持续
  • 原文地址:https://www.cnblogs.com/daneres/p/4726633.html
Copyright © 2020-2023  润新知