编写jsp程序,使用<c:choose>、<c:when>、<c:otherwise>标签根据当前是星期几显示提示中文信息
时间: 2024-06-01 08:11:35 浏览: 88
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
//获取当前的星期几
java.util.Calendar cal = java.util.Calendar.getInstance();
int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
%>
<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:when test="${dayOfWeek == 7}">
<p>今天是星期六,祝您有一个愉快的周末。</p>
</c:when>
<c:otherwise>
<p>获取星期信息失败,请稍后再试。</p>
</c:otherwise>
</c:choose>
阅读全文