<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.Random" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>幸运大抽奖</title>
</head>
<body>
<%Random rnd=new Random();%>
<!-- 将抽取的幸运数字保存到变量中 -->
<c:set var="luck">
<%=rnd.nextInt(10)%>
</c:set>
<c:choose>
<c:when test="${luck==1}">恭喜你,中了1等奖!</c:when>
<c:when test="${luck==2}" >恭喜你,中了2等奖!</c:when>
<c:when test="${luck==3}">恭喜你,中了3等奖!</c:when>
<c:otherwise>谢谢您的参与!</c:otherwise>
</c:choose>
</body>
</html>
![](https://img2024.cnblogs.com/blog/35695/202407/35695-20240713070336838-1837943664.jpg)