您的位置:首页 > Web前端 > JavaScript

【JSP 标签】格式化日期

2017-02-22 10:44 405 查看
在使用JSP开发页面时,java.util.Date在JSP页面直接输出的格式不好看,需要进行格式化。

<%@ 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: