问题描述:使用c:choose时,域对象获取的值的类型不一致时,报错(org.apache.jasper.JasperException:在第[24]行处理JSP页面[/zh_en.jsp]时发生异常)
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>星期中英对照</title>
</head>
<body>
<%
request.setAttribute("day", "m");
%>
${day}
<c:choose>
<c:when test="${day == 'm'}">//注意这里 "${day == "m"}"
<p>星期一</p>
</c:when>
<c:when test="${day == 2}">
<p>星期二</p>
</c:when>
<c:when test="${day == 3}">
<p>星期三</p>
</c:when>
<c:when test="${day == 4}">
<p>星期四</p>
</c:when>
<c:when test="${day == 5}">
<p>星期五</p>
</c:when>
<c:when test="${day == 6}">
<p>星期六</p>
</c:when>
<c:when test="${day == 7}">
<p>星期天</p>
</c:when>
<c:otherwise>
<p style="color: #f20d0d;">内容不对哟</p>
</c:otherwise>
</c:choose>
</body>
</html>
注意:类型