| |
| Jsp学习笔记(三)-----Jsp语法! |
| |
发布者: 发布时间:2006-05-07 |
|
|
|
<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>
|
| (转载文章请保留出处:北天JAVA技术网(www.java114.com)) |
| |
| 更多精彩文章: |
| 记住JSP内置对象的简单方法 |
| Jsp学习笔记(一)!-------理解Jsp技术! |
| jsp研究(一) |
| 建立自己的jsp app目录 |
| jsp+mysql制作简单的留言板(6) |
| jsp+mysql制作简单的留言板(5) |
| |
| 最近评论: |
|
|
| 冰封的往事! |
| wow power leveling,wow gold,wow power leveling,wow gold
max(1081) |
|
|
| 飞舞的传奇! |
| 传世私服,传世私服.传奇世界私服传奇世界私服,传世私服传世私服, 传奇世界私服传奇世界私服.传奇私服传奇私服. max(7137) |
|
|
| |
| 免责声明:该文章由网友发表,如果对您造成侵权,请联系站长。 |
|