我在我的演講下面的代碼在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