国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

Jsp學習筆記(三)-----Jsp語法!

2024-09-05 00:19:30
字體:
來源:轉載
供稿:網友
1 <html>
<head>
<title>
helloworld example
</title>
</head>
<body>
--------------
<%
string msg="this is a jsp test";
out.print("hello world");
%>//java模塊 申明msg為字符串變量
--------------
<h2> <%=msg%></h2>//輸出變量
</body>
</html>
2 在客戶端的源代碼中顯示注釋:

<!--this file displays the user login screen,and the time is <%=(new java.util.date()).tostring()%>-->//
<html>
<head>
<title>
helloworld example
</title>
</head>
<body>
<%
string msg="我是tomcat";
out.print("hello world");
%>
<h2> <%=msg%></h2>
</body>
</html>
3 隱藏注釋

<!--this file displays the user login screen,and the time is <%=(new java.util.date()).tostring()%>-->
<%@page language="java"%>//客戶端看不到注釋
<html>
<head>
<title>
helloworld example
</title>
</head>
<body>
<%
string msg="我是tomcat";
out.print("hello world");
%>
<h2> <%=msg%></h2>
</body>
</html>
4 聲明變量,方法和新的類

<!--this file displays the user login screen,and the time is <%=(new java.util.date()).tostring()%>-->
<%@page language="java"%>
<html>
<head>
<title>
helloworld example
</title>
</head>
<body>
<%!
public class university
{
string name,city;
university(string name,string city)
{
this.name=name;
this.city=city;
}
public string getname()
{
return name;
}
public string getcity()
{
return city;
}
}
%>
<%
university university1=new university("山東科技大學","青島市");
university university2=new university("山東大學","濟南市");
out.println("第一所大學是:");
out.println(university1.getname()+"<br>");

out.println(university1.getcity()+"<br>");

out.println("第二所大學是:");
out.println(university2.getname()+"<br>");

out.println(university2.getcity());
%>

</body>
</html>
5 表達式
<%@page language="java"%>
<html>
<head>
<title>
helloworld example
</title>
</head>
<body>
<h2>a test of expression</h2>
<%=(new java.util.date()).tostring()%>//表達式的結尾無;結束

</body>
</html>


菜鳥學堂:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阜康市| 阳曲县| 离岛区| 平昌县| 西充县| 富川| 武强县| 漳平市| 岐山县| 古丈县| 台东县| 台南县| 石城县| 临沧市| 应用必备| 泗洪县| 临沂市| 庆安县| 桦川县| 额尔古纳市| 秦皇岛市| 德兴市| 凯里市| 玛曲县| 怀宁县| 库车县| 乐昌市| 房山区| 安福县| 左贡县| 新绛县| 泗水县| 桃江县| 札达县| 东丽区| 喀喇| 信阳市| 无极县| 远安县| 太原市| 建昌县|