欢迎光临
我们一直在努力

Jsp学习笔记(三)-----Jsp语法!-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Jsp学习笔记(三)-----Jsp语法!-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章