编写JSP程序,使用<c:choose>、<c:when>和<c:otherwise>标签根据当前是星期几而显示不同的提示信息
时间: 2024-05-02 15:22:12 浏览: 102
```jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
// 获取当前星期几
int dayOfWeek = 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>
```
阅读全文