编写jsp程序,使用<c:choose>、<c:when>、<c:otherwise>标签根据当前是星期几显示提示信息
时间: 2024-05-24 15:10:03 浏览: 100
JSTL标签库
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>显示星期提示信息</title>
</head>
<body>
<c:set var="dayOfWeek" value="<%=java.time.LocalDate.now().getDayOfWeek().getValue()%>"/>
<c:choose>
<c:when test="${dayOfWeek == 1}">
<p>今天是星期一,加油!</p>
</c:when>
<c:when test="${dayOfWeek == 2}">
<p>今天是星期二,奋斗!</p>
</c:when>
<c:when test="${dayOfWeek == 3}">
<p>今天是星期三,努力!</p>
</c:when>
<c:when test="${dayOfWeek == 4}">
<p>今天是星期四,加油!</p>
</c:when>
<c:when test="${dayOfWeek == 5}">
<p>今天是星期五,奋斗!</p>
</c:when>
<c:when test="${dayOfWeek == 6}">
<p>今天是星期六,愉快!</p>
</c:when>
<c:otherwise>
<p>今天是星期日,放松一下吧!</p>
</c:otherwise>
</c:choose>
</body>
</html>
阅读全文