加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

脚本和注释

发布时间:2020-12-15 07:30:29 所属栏目:Java 来源:网络整理
导读: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 在控制台输出运算结果

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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读