<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page contentType="text/html;charset=gb2312"%>
<%@ taglib uri="/struts-logic" prefix="logic" %>
<%@ taglib uri="/struts-bean" prefix="bean" %>
<%@ taglib uri="/struts-html" prefix="html" %>
<%@ taglib uri="/jstl/c" prefix="c" %>
<!--初始化，设置一些属性-->
<jsp:useBean id="user" class="com.jspdev.ch17.User" scope="page"/>
<c:set target="${user}" property="userName" value="demouser"/>
<c:set target="${user}" property="age" value="25"/>
<c:set target="${user}" property="password" value="xxxxxx"/>
<jsp:useBean id="departmentBean" class="com.jspdev.ch17.DepartmentBean" scope="session"/>
<c:set var="departments" value="${departmentBean.departments}"/>
<c:set var="testProperty" value="testProperty_value" scope="session"/>
<html>
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="<html:rewrite page="/rr.css" />" rel="stylesheet" type="text/css">
<title><bean:message key="title.studyBean"/></title>
</head>
<body>
<center>
<hr>
        <!--在JSP中是否存在名称为user的bean-->
        <logic:present name="user">
              <b><i><font size="2" color="BLACK">Welcome <bean:write name="user" property="userName" />!</font></i></b><br/>
        </logic:present>        
        
           <logic:notEmpty name="user" property="userName">
              <b><i><font size="2" color="BLACK">user.userName 非空，它的值是： <bean:write name="user" property="userName" />!</font></i></b><br/>
        </logic:notEmpty>
        
        <logic:lessThan name="user" property="age" value="30">  
           <b><i><font size="2" color="BLACK">user.age<30，它的值是： <bean:write name="user" property="age" />!</font></i></b><br/>
         </logic:lessThan>
      <hr>迭代的使用：<br>
      <table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="5">
         <tr bgcolor="#cccccc"> <td><b>dept ID</b></td>  <td><b>名称 </b></td>   </tr>
       <logic:iterate id="depts" name="departments" >
	  <tr bgcolor="#FFFF88">
	  <td>
          <bean:write name="depts" property="id" /></td>
         <td>
          <bean:write name="depts" property="name" /></td>
        </tr>
        </logic:iterate>
     </table>
</center>
</body>
</html>