首页 > 编程 > JSP > 正文

jsp !if else语句使用方法

2019-11-02 15:41:26
字体:
来源:转载
供稿:网友

if else在大部份编程语言中都是这样使用的,我们今天来简单的介绍一下关于jsp教程 中的if else 与多重条件判断。

<HTML>
  <HEAD>
    <TITLE>Using the if Statement</TITLE>
  </HEAD>

  <BODY>
    <H1>Using the if Statement</H1>
    <%
        int value = 10;

        if(value > 0)
            out.println("Absolute value of " + value + " = " + value);
    %>
  </BODY>
</HTML>
简单对比

<HTML>
  <HEAD>
    <TITLE>Using Compound Statements</TITLE>
  </HEAD>

  <BODY>
    <H1>Using Compound Statements</H1>
    <%
        int value = 10;

        if(value > 0) {
            out.println("The number was positive.");               
            out.println("Absolute value of " + value + " = " + value);
        }
    %>
  </BODY>
</HTML>

if else

<HTML>
  <HEAD>
    <TITLE>Nested if Statements</TITLE>
  </HEAD>

  <BODY>
    <H1>Nested if Statements</H1>
    <%
        double value = 2;

        if (value != 0) {
            if (value > 0)
            &nbs

最新搞笑图片[www.62-6.com/1/pic/]
p;  out.println("The result = " + (1 / value));
            else
               out.println("Sorry, we need a positive number.");
        }
    %>
  </BODY>
</HTML>
多个条件if else

<HTML>
  <HEAD>
    <TITLE>Using an if-else Ladder</TITLE>
  </HEAD>

  <BODY>
    <H1>Using an if-else Ladder</H1>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表