<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:useBean id="myDate" class="java.util.Date"/>
<c:choose> <c:when test = "${time == 'time'}"> <%--判断是否为空--%> <c:set target="${myDate}" property="time" value="${dataOne.date}"/> <p><fmt:formatDate value="${myDate}" type="both" pattern="yyyy-MM-dd" /></p> </c:when> <c:otherwise> <p><fmt:formatDate value="${dataOne.date}" pattern="yyyy-MM-dd" /></p> </c:otherwise> </c:choose>