- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于我的协议(protocol)最近发生了一些变化,我正在尝试更改管理面板中的一些代码。我想做的是将代码从 boolean 更改为 int。
旧协议(protocol):public static boolean GMSetDoubleExp(boolean)
原代码如下:
try
{
String dblexp_on = request.getParameter("dblexp_on");
if(dblexp_on == null){dblexp_on = "false";}
if(DeliveryDB.GMSetDoubleEXP(dblexp_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved Double Experience Points</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Double Experience Points Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
新协议(protocol):public static boolean GMSetDoubleExp(int)
这是我现在的代码:
try
{
int dblexp_on = Integer.parseInt(request.getParameter("dblexp_on"));
if(dblexp_on == 0){dblexp_on = (0);}
if(DeliveryDB.GMSetDoubleExp(dblexp_on = (1)))
{
//message += "<font color=\"#00cc00\"><b>Saved Double Experience Points</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Double Experience Points Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
即使我在运行页面时没有收到错误,它也会给我一条错误消息,指出它尚未保存。有人知道我做错了什么吗?
这是我的页面的完整代码。
<%@page import="protocol.*"%>
<%@include file="WEB-INF/.pwadminconf.jsp"%>
<%
boolean allowed = false;
if(request.getSession().getAttribute("ssid") == null)
{
out.println("<p align=\"right\"><font color=\"#ee0000\"><b>Login for Server configuration...</b></font></p>");
}
else
{
allowed = true;
}
%>
<table width="800" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="2">
<br>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table cellpadding="2" cellspacing="0" style="border: 1px solid #cccccc;">
<tr>
<th colspan="2" align="center" style="padding: 5;">
<font color="#ffffff"><b><%out.println(pw_server_name);%></b></font>
</th>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" style="border-bottom: 1px solid #cccccc;">
<iframe src="status.jsp" width="120" height="32" scrolling="no" frameborder="no" style="border: 0;"></iframe>
</td>
</tr>
<tr>
<td>
EXP Rate:
</td>
<td>
<%out.println(pw_server_exp);%>
</td>
</tr>
<tr>
<td>
SP Rate:
</td>
<td>
<%out.println(pw_server_sp);%>
</td>
</tr>
<tr>
<td>
Drop Rate:
</td>
<td>
<%out.println(pw_server_drop);%>
</td>
</tr>
<tr>
<td>
Coins Rate:
</td>
<td>
<%out.println(pw_server_coins);%>
</td>
</tr>
<tr>
<td colspan="2" style="border-top: 1px solid #cccccc;">
<%out.println(pw_server_description);%>
</td>
</tr>
</table>
</td>
<td align="center" valign="top">
<%
if(allowed)
{
String message = new String("<br>");
// ### Apply Changes ###
if(request.getParameter("process") != null)
{
if(request.getParameter("process").compareTo("save") == 0)
{
message = "<font color=\"#00cc00\"><b>Saved All Values<b></font>";
try
{
int max = Integer.parseInt(request.getParameter("users_max"));
if(DeliveryDB.SetMaxOnlineNum(max, max))
{
//message += "<font color=\"#00cc00\"><b>Saved Maximum User Number<b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Maximum User Number Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving Maximum User Number Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
int lambda_value = Integer.parseInt(request.getParameter("lambda_value"));
if(DeliveryDB.GMSetLambda(lambda_value))
{
//message += "<font color=\"#00cc00\"><b>Saved Lambda Value<b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Lambda Value Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving Lambda Value Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String dblexp_on = request.getParameter("dblexp_on");
if(dblexp_on == null){dblexp_on = "false";}
if(DeliveryDB.GMSetDoubleEXP(dblexp_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved Double Experience Points</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Double Experience Points Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving Double Experience Points Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String dblsp_on = request.getParameter("dblsp_on");
if(dblsp_on == null){dblsp_on = "false";}
if(DeliveryDB.GMSetDoubleSP(dblsp_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved Double Skill Points</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Double Skill Points Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving Double Skill Points Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String dbldrop_on = request.getParameter("dbldrop_on");
if(dbldrop_on == null){dbldrop_on = "false";}
if(DeliveryDB.GMSetDoubleObject(dbldrop_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved Double Droprate</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Double Droprate Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving Double Droprate Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String dblcoin_on = request.getParameter("dblcoin_on");
if(dblcoin_on == null){dblcoin_on = "false";}
if(DeliveryDB.GMSetDoubleMoney(dblcoin_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved Double Coins</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving Double Coins Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving Double Coins Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String nomail_on = request.getParameter("nomail_on");
if(nomail_on == null){nomail_on = "false";}
if(DeliveryDB.GMSetNoMail(nomail_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved No-Mail Mode</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving No-Mail Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving No-Mail Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String nofaction_on = request.getParameter("nofaction_on");
if(nofaction_on == null){nofaction_on = "false";}
if(DeliveryDB.GMSetNoFaction(nofaction_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved No-Faction Mode</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving No-Faction Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving No-Faction Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String notrade_on = request.getParameter("notrade_on");
if(notrade_on == null){notrade_on = "false";}
if(DeliveryDB.GMSetNoTrade(notrade_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved No-Trade Mode</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving No-Trade Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving No-Trade Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String noshop_on = request.getParameter("noshop_on");
if(noshop_on == null){noshop_on = "false";}
if(DeliveryDB.GMSetNoSellPoint(noshop_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved No-PlayerShop Mode</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving No-PlayerShop Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving No-PlayerShop Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
try
{
String noauction_on = request.getParameter("noauction_on");
if(noauction_on == null){noauction_on = "false";}
if(DeliveryDB.GMSetNoAuction(noauction_on.equals("true")))
{
//message += "<font color=\"#00cc00\"><b>Saved No-Auction Mode</b></font><br>";
}
else
{
//message += "<font color=\"#ee0000\"><b>Saving No-Auction Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
catch(Exception e)
{
//message += "<font color=\"#ee0000\"><b>Saving No-Auction Mode Failed</b></font><br>";
message = "<font color=\"#ee0000\"><b>Saving of one or more Values Failed<b></font>";
}
}
}
// ### END Apply Changes ###
// ### Get Current Values ###
String users_max = new String("");
String users_vmax = new String("");
String users_online = new String("");
{
Integer[] user = new Integer[3];
DeliveryDB.GetMaxOnlineNum(user);
if(user[0] == null){user[0] = new Integer(-1);}
if(user[1] == null){user[1] = new Integer(-1);}
if(user[2] == null){user[2] = new Integer(-1);}
users_max = user[0].toString();
users_vmax = user[1].toString();
users_online = user[2].toString();
}
String lambda = new String("");
{
lambda = Integer.toString(DeliveryDB.GMGetLambda());
}
String double_exp = new String("");
{
byte status = DeliveryDB.GMGetDoubleExp();
if(status == (byte)1){double_exp = "checked=\"checked\"";}
}
String double_sp = new String("");
{
byte status = DeliveryDB.GMGetDoubleSP();
if(status == (byte)1){double_sp = "checked=\"checked\"";}
}
String double_drop = new String("");
{
byte status = DeliveryDB.GMGetDoubleObject();
if(status == (byte)1){double_drop = "checked=\"checked\"";}
}
String double_coin = new String("");
{
byte status = DeliveryDB.GMGetDoubleMoney();
if(status == (byte)1){double_coin = "checked=\"checked\"";}
}
String mail = new String("");
{
byte status = DeliveryDB.GMGetNoMail();
if(status == (byte)1){mail = "checked=\"checked\"";}
}
String faction = new String("");
{
byte status = DeliveryDB.GMGetNoFaction();
if(status == (byte)1){faction = "checked=\"checked\"";}
}
String trade = new String("");
{
byte status = DeliveryDB.GMGetNoTrade();
if(status == (byte)1){trade = "checked=\"checked\"";}
}
String shop = new String("");
{
byte status = DeliveryDB.GMGetNoSellPoint();
if(status == (byte)1){shop = "checked=\"checked\"";}
}
String auction = new String("");
{
byte status = DeliveryDB.GMGetNoAuction();
if(status == (byte)1){auction = "checked=\"checked\"";}
}
// ### END Get Current Values ###
// ### Show Form ###
out.println("<form action=\"index.jsp?page=server&process=save\" method=\"post\" style=\"margin: 0px;\">");
out.println("<table cellpadding=\"2\" cellspacing=\"0\" style=\"border: 1px solid #cccccc;\">");
out.println("<tr><th colspan=\"3\" align=\"center\" style=\"padding: 5px;\">SERVER CONFIGURATION</th>");
out.println("<tr bgcolor=\"#f0f0f0\"><td colspan=\"3\" align=\"center\">" + message + "</td>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Max. Online Users / Virtual Max. Online Users</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"users_max\" type=\"text\" value=\"" + users_max + "\" style=\"width: 40px; text-align: center;\"></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Set Lambda Value</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"lambda_value\" type=\"text\" value=\"" + lambda + "\" style=\"width: 40px; text-align: center;\"></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn Double Experience Points On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"dblexp_on\" type=\"checkbox\" value=\"true\" " + double_exp + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn Double Skill Points On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"dblsp_on\" type=\"checkbox\" value=\"true\" " + double_sp + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn Double Droprate On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"dbldrop_on\" type=\"checkbox\" value=\"true\" " + double_drop + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn Double Coins On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"dblcoin_on\" type=\"checkbox\" value=\"true\" " + double_coin + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn No-Mail Mode On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"nomail_on\" type=\"checkbox\" value=\"true\" " + mail + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn No-Faction Mode On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"nofaction_on\" type=\"checkbox\" value=\"true\" " + faction + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn No-Trade Mode On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"notrade_on\" type=\"checkbox\" value=\"true\" " + trade + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn No-PlayerShop Mode On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"noshop_on\" type=\"checkbox\" value=\"true\" " + shop + "></td></tr>");
out.println("<tr><td style=\"border-top: 1px solid #cccccc;\">Turn No-Auction Mode On / Off</td><td align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input name=\"noauction_on\" type=\"checkbox\" value=\"true\" " + auction + "></td></tr>");
out.println("<tr><td colspan=\"2\" align=\"center\" style=\"border-top: 1px solid #cccccc;\"><input type=\"image\" src=\"include/btn_save.jpg\" style=\"border: 0px;\"></td></tr>");
out.println("</table>");
out.println("</form>");
// ### END Show Form ###
}
%>
</td>
</tr>
</table>
最佳答案
相等比较的运算符是==
你的代码应该是:
if(DeliveryDB.GMSetDoubleExp(dblexp_on == (1)))
=
是赋值运算符
如果 GMSetDoubleExp
方法需要一个整数,那么您应该使用:
if(DeliveryDB.GMSetDoubleExp(dblexp_on))
关于java - 如何将java中的boolean代码更改为int代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16658942/
我正在尝试从文本文件构建 boolean 值[][]。我正在读取每个字符,存储在 ArrayList 中(1 为真,0 为假)。我试过 ArrayList,但出现编译错误,意外元素。因此,我构建了一个
我想知道编程语言中的运算符优先级是否取决于实现,还是所有语言都遵循固定的规则。并且,如果可能的话,您可以先排序以下具有最高优先级的运算符吗:AND,OR,NOT,XOR。 最佳答案 我在Google上
这是同样的事情,对吗?还是有细微的差别?我只是想确保我没有误解任何事情。 最佳答案 通过简单地将 AND 替换为 OR 以及将 OR 替换为 AND 即可生成 boolean 对偶。补码本身不受影响,
我想这对于大多数优秀的程序员来说是微不足道的,但我已经习惯使用 true 进行编程。和 false 2、当我遇到0和1的时候,我永远记不住哪一个是真的,哪一个是假的。 有什么建议? 1好:I mean
我正在尝试将此 Java 示例转换为 Kotlin: Gson gson = new GsonBuilder() .registerTypeAdapter(Boolean.class,
下面的代码打印 true。 public static void main(String[] args) { Boolean test = false; test =
我在处理应该导致在 iReport 中显示或隐藏 strip 的表达式时遇到困难。 这些是我拥有的变量: Integer mainGroupInt = Integer.valueOf(5); Inte
以下编码错误可能是因为 Boolean equals(Object) 方法不需要 boolean/Boolean 参数: private void foo() { Boolean isSome
我想简化一个 boolean 表达式。 表达式是这样的 X1 xor (X2 || X3 && X4 || x5) 如何使用 boolean 代数规则简化此表达式。 而且我想将上面的 boolean
我正在使用一些工具,它可以确定特定事务是否成功的唯一方法是它是否通过了各种检查。但是,它的方式有限制,一次只能做一次检查,而且必须是顺序的。一切都必须从左到右计算。 例如, A || C && D 它
在大多数编程语言中,1和 0可以用来代替 True和 False .然而,根据我的经验,整数似乎总是更容易使用。 以下是我的意思的一些示例: if x is True: x = False else:
我有一个 boolean 方程,想简化它。帮忙解决一下。 bool needLoad = isA || (!isA && !isB); 之后我使用 if (needLoad){ if (
我认为这始终是正确的 x || (x && y) 相当于 x 如果是这样,那条法律叫什么?我什至不知道如何通过 Google 搜索该信息。 最佳答案 它被称为 Redundancy Law . A +
是否有任何现有的方法或功能模块可以有效地翻转 boolean 值? 如果我必须定义自己的实用方法,我想出了一个简单的实现,但我想知道这是否是最有效的方法: IF iv_bool = abap_true
我有这个表达式:X'YZ'+X'YZ+XY'Z'+XYZ'+XYZ('表示不是)我知道答案是 Y+XZ' 但我陷入了最后一部分。有人可以帮我吗? 这是我到目前为止得到的: X'YZ' + X'YZ +
openCL 支持 boolean 变量吗?我目前正在使用 JOCL (java) 编写我的 openCL 调用代码,但我没有看到任何有关 boolean 值的信息。 最佳答案 tl;dr:是的,但您
我认为这是对的 x || (x && y) 相当于 x 如果是这样,那条法律叫什么?我什至不确定我会如何使用 Google。 最佳答案 它叫做 Redundancy Law . A + A·B = A
我有一些功能,例如 (A and ( B or c)) or (D and E and (F or H or R or P ))) 我想将该函数转换为仅包含 and 操作的函数(当然如果可能的话)我发
我参加了编程面试,由 3 名面试官组成,每人 45 分钟。虽然前两位面试官给了我 2-3 个简短的编码问题(即反向链表、使用 rand(5) 实现 rand(7) 等),但第三位面试官使用了整个时间段
如果我只想检查某事是否不可能(即,我不会使用类似 if(possible) 的东西),我应该将 boolean 值命名为 notPossible并使用 if(notPossible)或者我应该命名它p
我是一名优秀的程序员,十分优秀!