One: Define a class
Package com.cloud.Demo1;
public class Cat {
private String name;
private int age;
Public String GetName () {
return name;
}
public void SetName (String name) {
THIS.name = name;
}
public int getage () {
return age;
}
public void Setage (int.) {
This.age = age;
}
}
Two: c_if label
<%@ page language= "java" import= "Java.util.*,com.cloud.demo1.cat" pageencoding= "UTF-8"%>
<%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>my JSP ' c_if.jsp ' starting page</title>
<body>
<%
Request.setattribute ("A", "Hello");
Request.setattribute ("Age", "10");
Cat cat1=new Cat ();
Cat1.setname ("small white");
Cat1.setage (10);
Request.setattribute ("Cat", CAT1);
%>
<!--determine if the value of a variable is not hello--
<c:if test= "${a== ' Hello '}" >
Ok!
</c:if>
<c:if test= "" >
bad!
</c:if>
<c:if test= "${age==20}" >
equals 20
</c:if>
<c:if test= "${age<20 and Age>5}" >
Age<20 and Age>5
</c:if>
<c:if test= "${cat.age>3}" >
The age of the mouse >3
</c:if>
</body>
Three: C_choose label
<%@ page language= "java" import= "Java.util.*,com.cloud.demo1.cat" pageencoding= "UTF-8"%>
<%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>my JSP ' c_choose.jsp ' starting page</title>
<body>
<%
Cat cat1=new Cat ();
Cat1.setname ("small white");
Cat1.setage (10);
Request.setattribute ("Cat", CAT1);
%>
<c:choose>
<c:when test= "${cat.age<3}" >
<font color= "Red" > Mouse very small </font>
</c:when>
<c:when test= "${cat.age>3 and Cat.age<8}" >
<font color= "Blue" > Mouse young </font>
</c:when>
<c:otherwise>
<font color= "Yellow" > Mouse old </font>
</c:otherwise>
</c:choose>
</body>
Copyright Notice: Bo Master original articles, reproduced please indicate the source. Http://blog.csdn.net/dzy21
JSTL Select tags