3.请按要求编写一个c_ choose.jsp页面,使用<c:choose>、<c:when>和<c:otherwise>这三个标签完成多个条件选择的程序。要求: (1)访问c_choose.jsp页面时不传递参数时,浏览器中显示的信息为unknown user (2)访问c_choose.jsp页面时传递一个参数username=itcast时,浏览器中显示的信息为itcast is a manager (3)访问c_choose.jsp页面时传递username参数为itcast以外的值时,浏览器中显示的信息为you are a manager
时间: 2024-02-21 09:01:27 浏览: 66
在多个页面传递jsp参数
以下是 c_choose.jsp 页面的代码:
```html
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>c:choose Demo</title>
</head>
<body>
<c:choose>
<c:when test="${param.username eq 'itcast'}">
${param.username} is a manager
</c:when>
<c:when test="${not empty param.username}">
unknown user
</c:when>
<c:otherwise>
you are a manager
</c:otherwise>
</c:choose>
</body>
</html>
```
当访问 c_choose.jsp 页面时,如果不传递参数,则会显示 "unknown user"。如果传递的参数 username 的值为 "itcast",则会显示 "itcast is a manager"。如果传递的参数 username 的值不为 "itcast",则会显示 "you are a manager"。
阅读全文