为了达到如下效果,进行医生列表的显示
要求:动态读取科室信息,按照上图方式显示,每行显示三个医生的信息,点击医生名称即可进入医生的详细信息,如下图所示
关键代码如下所示
<%@ page session="true" import="java.text.SimpleDateFormat,java.util.Date, java.util.HashSet"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" %>
<%@ page import="java.util.*,org.opencms.jsp.*" %>
<!-- 定义全局变量,用来存储所有科室信息-->
<%
HashSet<String> set = new HashSet<String>();
request.setAttribute("set",set);
%>
<!-- 显示列表信息-->
<div style="width:1000px">
<!-- 第一次遍历所有医生信息,将所有科室信息放到全局变量set中-->
<cms:contentload collector="allInFolderPriorityDateDesc" param="/doctor/doctor_%(number).html|doctor" >
<cms:contentaccess var="content" />
<c:set var="aa" value="${content.value['Division']}" scope="request" />
<%
set.add((request.getAttribute("aa")).toString());
%>
</cms:contentload>
<!--循环读取科室信息 -->
<c:forEach var="name" items="${set}">
<c:set var="gg" value="${name}" scope="request" />
<div style="width:322px; float:left">
<dl>
<dt class="STYLE26">
<c:out value="${name}" /> <!--读取科室信息-->
<cms:contentload collector="allInFolderPriorityDateDesc" param="/doctor/doctor_%(number).html|doctor" >
<cms:contentaccess var="content" />
<c:set var="bb" value="${content.value['Division']}" scope="request" />
<c:choose>
<c:when test="${name == bb}">
<dd style="display:inline" class="STYLE25" >
<div align="center"><a href="<cms:link><cms:contentshow element="%(opencms.filename)" /></cms:link>" ><cms:contentshow element="DoctorName" /></a></div> </dd>
</c:when>
</c:choose>
</dt>
</dl>
</cms:contentload>
</div>
</c:forEach>
</div>