gpt4 book ai didi

java - 在 [game.Game] 类型的 bean 中找不到有关属性 [bankOffer] 的任何信息

转载 作者:行者123 更新时间:2023-11-27 22:55:38 26 4
gpt4 key购买 nike

当前收到一个错误,指出无法找到我的 bean 中的 bankOffer 属性。

它来 self 的 game.jsp 文件,如下所示:

<%@page import="game.Briefcase"%>
<jsp:useBean id="game" class="game.Game" scope="session" />
<%
// If the 'open' parameter is received, it is converted to
// an integer and passed to the method setOpen. The value given
// is the corresponding index for the ArrayList Object.
if (request.getParameter("open") != null) {
game.caseOpen(Integer.parseInt(request.getParameter("open")));
}
// If the 'restart' parameter is given, then the restart method
// is invoked on the game bean.
if (request.getParameter("restart") != null) {
game.newgame();
}
// If the deal parameter is given, then it converts it to a Boolean
// value and performs a conditional test. If the parameter is true,
// then the deal has been made so the page is forwarded to the deal.jsp.
// Otherwise, the gameRound() is incremented cause it is NO DEAL!.
if (request.getParameter("deal") != null) {
if (Boolean.parseBoolean(request.getParameter("deal"))) {
game.setDeal(true);
} else {
game.nextround();
}
}
// If there is a Bank Offer, it will display the amount offered with
// two buttons to either accept or refuse.
if (!game.getDeal()) {
if (game.offerTime()) {%>
<div id="bank_offer">
<div id="bank_offer_title"></div>
<div id="deal_button" onclick="deal(true)"></div>
<div id="bank_offer_text">
<div id="bank_offer_amount">$<jsp:getProperty name="game" property="bankOffer" /></div>
<div id="bank_offer_message">Highest amount left: $<jsp:getProperty name="game" property="highestAmount" /></div>
</div>
<div id="nodeal_button" onclick="deal(false)"></div>
</div>
<%
// Otherwise, the Briefcases will be displayed along with a game message
// above the cases.
} else {
%>
<div id="game_message">
<div id="game_round">
<% if (game.getRound() > 0) { %>
Round: <jsp:getProperty name="game" property="round" />
<% } %>&nbsp;
</div>
<div id="game_text">
<jsp:getProperty name="game" property="message" />
</div>
</div>
<div id="cases">
<%
int index = 0;
// Iterates For Each Briefcase
for (Briefcase briefcase : game.getcases()) {
// If the Briefcase is not opened, then it is displayed as closed with the
// number assigned. Otherwise, if the Briefcase is opened then it is displayed
// as open with the amount value inside.
if (!briefcase.isOpened()) {
// If the Briefcase is the chosen case, then it will be displayed with
// 'Your Briefcase' on the image. The Briefcase's once pressed invokes
// a JavaScript function called openBriefcase() which passes the
// index. The function then invokes an Ajax call to the same .jsp which the
// html is then placed into the game container on the main index.jsp.
%>
<div onclick="openBriefcase(<%=index%>)" class="<%=(((game.getChosen() != null)
&& game.getChosen().equals(briefcase)) ? "briefcase_chosen" : "briefcase_closed")%>">
<div class="briefcase_number"><%=briefcase.getNumber()%></div></div>
<%} else {
// Once the case is opened it gets displayed with an open background
// with the case amount centered.
%>
<div class="briefcase_open">
<div class="briefcase_amount">$<%=briefcase.getValue()%></div>
</div>
<%}
index++;
}%>
</div>
<%
}
} else { %>
<div id="deal_message">
Deal $<jsp:getProperty name="game" property="bankOffer" />
</div>
<%
}
%>

Hmu 链接所需的任何其他文件。前一个文件是索引 jsp,它可以很好地加载我的其他动态内容,但它没有加载 game.jsp。

帮助将不胜感激,这是我第一次不得不以任何广泛的方式使用 jsp,所以我现在不知所措..

最佳答案

确保 game.Game 类有一个名为 bankOffer 的 bean 属性(不仅仅是一个字段)。 Java bean 属性由其 getter 和 setter 定义,因此要使 bankOffer 成为属性,类 game.Game 必须包含公共(public)方法 getBankOffer(如果是 boolean 属性,则为 isBankOffer)和 setBankOffer

关于java - 在 [game.Game] 类型的 bean 中找不到有关属性 [bankOffer] 的任何信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56088990/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com