在使用JSP開發頁面時,java.util.Date在JSP頁面直接輸出的格式很差看,須要進行格式化。html
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <c:set var="rootPath" value="${pageContext.request.contextPath}" scope="request"/> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <table> <thead> <tr> <th>繳費標誌</th> <th>繳費時間</th> <th>操做</th> </tr> </thead> <tbody> <c:forEach items="${userAcctList}" begin="0" step="1" var="userAcct"> <tr> <td> <c:if test="${userAcct.payedFlag==1}"> <img alt="已交費" src="/img/icon/smile.jpeg"> </c:if> <c:if test="${userAcct.payedFlag!=1}"> <img alt="未交費" src="/img/icon/han.jpg"> </c:if> </td> <!-- 日期格式化標籤 --> <td><fmt:formatDate pattern="yyyy-MM-dd" value="${userAcct.payTime}"/></td> <td> <c:if test="${userAcct.payedFlag!=1}"> <a href="#">交費</a> </c:if> </td> </tr> </c:forEach> </tbody> </table> </body> </html>