<%@page import="cn.hncu.domain.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
table{
border:1px solid black;
border-collapse: collapse;
width:200px;
}
td{
border:1px solid black;
}
</style>
</head>
<body>
<H2>用戶信息如下</H2>
用戶姓名:${user.name}<br/>
用戶年齡:${user.age}<br/>
<p>車輛信息如下:</p>
<table>
<tr> <th>車名</th> <th>編號</th> <th>顏色</th> </tr>
<%
Car cs[] = ((User) request.getAttribute("user")).getCars();
for( Car c : cs ){
pageContext.setAttribute("c", c);
%>
<tr> <td> ${c.name} </td> <td>${c.id}</td> <td>${c.color} </td> </tr>
<%
}
%>
</table>
<c:if test="${!empty user.cars}">
<hr/>
<h3>JSTL出場</h3>
<table>
<tr> <th>車名</th> <th>編號</th> <th>顏色</th> </tr>
<!-- for( Car c: cars) -->
<c:forEach items="${user.cars}" var="c" varStatus="idx">
<tr> <td>${idx.count} ${c.name} </td> <td>${c.id}</td> <td>${c.color} </td> </tr>
</c:forEach>
</table>
</c:if>
</body>
</html>