我在我的演讲下面的代码在GWT MVP应用:GWT:字符串比较不工作
public void onFailure(ServerFailure error) {
String errCode = error.getMessage();
Window.alert(errCode);
Window.alert("Server Error: pleaseEnterQuestion");
if(errCode == "Server Error: pleaseEnterQuestion")
Window.alert("same");
else
Window.alert("different");
}
前两个警报长得一模一样。第三个提示是different
。但我期望它是same
。
作为一个好奇的旁注:在Javascript中==工作正常(因为它比较值)。 GWT将String.equals转换为(或多或少)。所以这段代码将以编译模式(生产模式)工作,但不能进入开发者模式(调试)......说:**请使用等于!!! ** :) – helios 2011-05-11 10:32:56