zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    C++复制构造函数,类型转换构造函数,析构函数,引用,指针常量和常量指针
    POJ1611(The Suspects)--简单并查集
    最小生成树-Kruskal算法
    POJ1861(Network)-Kruskal
    POJ1979(Red and Black)--FloodFill
    [转]全网最!详!细!tarjan算法讲解
    POJ1573(Robot Motion)--简单模拟+简单dfs
    最小生成树-Prim算法
    POJ3368(Frequent values)--线段树
    POJ3255(Roadblocks)--次短路径
  • 原文地址:https://www.cnblogs.com/daneres/p/4726633.html
Copyright © 2011-2022 走看看