我是jsp的新手, 抱歉基本问题和表达不清楚。
为什么我无法从请求范围设置的第一个jsp文件中获取属性。
但会议范围确实没问题。 我认为它们都是由请求范围提供的。
非常感谢!!
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean id="myBean" class="ch05_04.LotteryBean" scope="session"/>
<!--I had to use the session scope to deliver the property what I set.-->
<!--why i couldn't use request scope-->
<jsp:setProperty name="myBean" property="lowerBound" value="1" />
<jsp:setProperty name="myBean" property="upperBound" value="49" />
<jsp:setProperty name="myBean" property="ballNumber" value="6" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!--This is First.jsp-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查詢名牌(Lab05_04)</title>
</head>
<body>
<h2>查詢名牌</h2>
<Form action="Second.jsp" method="POST">
訪客姓名:<input type="text" name="visitor" size = "10"><P/>
<input type="submit" value="確定"><P/>
</Form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!--This is Second.jsp-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>報明牌</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<H2>卜籤求明牌</H2>
${param.visitor},您好,<BR>
您的明牌為:
<jsp:useBean id="myBean" class="ch05_04.LotteryBean" scope="session"/>
<!--I had to use the session scope to accept the property what I set.-->
<!--why i couldn't use request scope-->
<jsp:getProperty name="myBean" property="luckyNumbers"/>
</body>
</html>
&#13;