1、jsp脚本:
(1)<% java代码 %>
<h3> <% out.println("Today is the Seventieth Anniversary of the founding of the People's Republic of China."); %> </h3>
在页面输出:
<h3> <% int a=9,b=9; System.out.println(a*b); %> </h3>
在控制台输出运算结果。
会被翻译到service方法内部。
翻译后为:
int a=9,b=9; System.out.println(a*b);
(2)<%=java变量或表达式>
<h3>
<%=123%>
</h3>
<h3> <%int a=9;%> <%=(a*a)%> </h3>
会被翻译到service方法内部的out,println();
即:输出到页面。
(3)<%! java代码 %>
<h3> <%! String string="Today is the Seventieth Anniversary of the founding of the People's Republic of China.";%> <%=string%> </h3>
加! 号后会被翻译到成员的位置,否则翻译到service方法内部。
2、注释:<%-- --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>jsp</title> </head> <body bgcolor="aqua"><%--注释--%> <h3> <%! String string="Today is the Seventieth Anniversary of the founding of the People's Republic of China.";%> <%=string%> </h3> </body> </html>