编写JSP程序,使用<c:choose>、<c:when>和<c:otherwise>标签根据当前是星期几而显示不同的提示信息
时间: 2024-05-19 17:13:00 浏览: 74
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<title>显示不同的提示信息</title>
</head>
<body>
<h1>根据当前是星期几而显示不同的提示信息</h1>
<c:set var="dayOfWeek" value="${fn:substring(fn:toLowerCase(fn:formatDate(now(), 'EEEE')), 0, 3)}"/>
<c:choose>
<c:when test="${dayOfWeek == 'mon'}">
<p>今天是星期一,加油!</p>
</c:when>
<c:when test="${dayOfWeek == 'tue'}">
<p>今天是星期二,别忘了完成任务!</p>
</c:when>
<c:when test="${dayOfWeek == 'wed'}">
<p>今天是星期三,中午休息一下吧!</p>
</c:when>
<c:when test="${dayOfWeek == 'thu'}">
<p>今天是星期四,好好工作!</p>
</c:when>
<c:when test="${dayOfWeek == 'fri'}">
<p>今天是星期五,周末就快到了!</p>
</c:when>
<c:when test="${dayOfWeek == 'sat'}">
<p>今天是星期六,出去玩一下吧!</p>
</c:when>
<c:otherwise>
<p>今天是星期天,放松一下心情!</p>
</c:otherwise>
</c:choose>
</body>
</html>
阅读全文