如何在JSP页面中编写switch语句?

以下是在JSP页面中使用switch语句的示例。

<%! int day = 3; %>

<html>

   <head>

      <title>SWITCH...CASE Example</title>

   </head>

   <body>

      <%

         switch(day) {

            case 0:

               out.println("It\'s Sunday.");

               break;

            case 1:

               out.println("It\'s Monday.");

               break;

            case 2:

               out.println("It\'s Tuesday.");

               break;

            case 3:

               out.println("It\'s Wednesday.");

               break;

            case 4:

               out.println("It\'s Thursday.");

               break;

            case 5:

               out.println("It\'s Friday.");

               break;

            default:

               out.println("It's Saturday.");

         }

      %>

   </body>

</html>

上面的代码将产生以下结果-

It's Wednesday.

以上是 如何在JSP页面中编写switch语句? 的全部内容, 来源链接: utcz.com/z/350220.html

回到顶部