jsp

位置:IT落伍者 >> jsp >> 浏览文章

jsp if else语句使用方法


发布日期:2021年08月29日
 
jsp if else语句使用方法

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

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

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

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

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

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

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

if else

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

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

if (value != ) {
if (value > )
outprintln("The result = " + ( / value));
else
outprintln("Sorry we need a positive number");
}
%>
</BODY>
</HTML>
多个条件if else

<HTML>
<HEAD>
<TITLE>Using an ifelse Ladder</TITLE>
</HEAD>

<BODY>
<H>Using an ifelse Ladder</H>
<%
String day = "Friday";

if(day == "Monday")
outprintln("Its Monday");
else if (day == "Tuesday")
outprintln("Its Tuesday");
else if (day == "Wednesday")
outprintln("Its Wednesday");
else if (day == "Thurssday")
outprintln("Its Thursday");
else if (day == "Friday")
outprintln("Its Friday");
else if (day == "Saturday")
outprintln("Its
else if (day == "Sunday")
outprintln("Its Sunday");
%>
</BODY>
</HTML>

以上是网为您介绍的jsp if else语句使用方法希望对您有所帮助

上一篇:如何用JSP读写Cookie

下一篇:JSP中日期的用法