如果希望選擇執行若干代碼塊中的一個
語法
switch(n)
{
case
執行代碼塊
break
case
執行代碼塊
break
default:
如果n即不是
}
工作原理
<HTML>
<HEAD>
<TITLE>Using the switch Statement</TITLE>
</HEAD>
<BODY>
<H
<%
int day =
switch(day) {
case
out
break;
case
out
break;
case
out
break;
case
out
break;
case
out
break;
case
out
break;
default:
out
}
%>
</BODY>
</HTML>
另一種情況
<HTML>
<HEAD>
<TITLE>Testing for Multiple Conditions</TITLE>
</HEAD>
<BODY>
<H
<%
int temperature =
switch(temperature) {
case
case
case
out
break;
case
case
case
out
break;
case
case
case
case
out
break;
case
case
case
case
case
case
out
break;
default:
out
}
%>
</BODY>
</HTML>
以上是網為您介紹的jsp switch語句的用法
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19902.html