我现在正在学习如何使用 jsp 和 bean,但无法理解我遇到的问题。
我正在尝试创建一个这样的bean:...
并收到错误消息:
java.lang.InstantiationException:在范围内找不到 bean 保留
我在网上四处查看,大多数人似乎建议使用 class="..." 而不是 type="...",或者使用 import 语句。我已经在做前者并尝试了后者……有什么想法吗?
这是豆子:
package homework10;
public class Reservation {
private int groupSize;
private String status;
private double cost;
private boolean triedAndFailed;
public Reservation(){
}
public void setGroupSize(int gs)
{
groupSize = gs;
}
public int getGroupSize()
{
return groupSize;
}
public void setStatus(String str)
{
this.status = str;
}
public String getStatus()
{
return status;
}
public void setCost(double cost)
{
this.cost = cost;
}
public double getCost()
{
return cost;
}
public void setTriedAndFailed(boolean bool)
{
this.triedAndFailed = bool;
}
public boolean isTriedAndFailed()
{
return triedAndFailed;
}
}
这是jsp页面的开头:
<head>
<!--<script type="text/javascript" src="functions8.js">
</script>-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BHC Calculator-HTML-validation + Servlet Version</title>
<jsp:useBean id = "reservation" class = "homework10.Reservation" scope = "session" />
</head>
提前致谢!