国产探花免费观看_亚洲丰满少妇自慰呻吟_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>


菜鳥學堂:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 钟祥市| 威海市| 卓资县| 甘南县| 南雄市| 潞城市| 正安县| 马鞍山市| 仙游县| 万年县| 简阳市| 元阳县| 许昌县| 井冈山市| 射阳县| 霞浦县| 法库县| 丹阳市| 剑河县| 章丘市| 华阴市| 南丰县| 搜索| 富宁县| 根河市| 荆门市| 武汉市| 合作市| 通河县| 蕲春县| 始兴县| 寻乌县| 拜泉县| 南江县| 仪征市| 三亚市| 彩票| 商丘市| 南郑县| 崇信县| 栾城县|