也许这是一个愚蠢的错误,对我来说仍然是不可见的,但我就是看不到它。
[...]
form.send("update.do?old=" + old + "&new=" + new, "post", function(loader, response) {
alert(response); // shows "something" without the quotes of course
//but the next code fragment shows "not got ya"
if(response.equals("something")){
alert("got ya");
}
else
alert("not got ya");
});
[...]
响应来自动作类。但我认为问题不在这里,因为我得到了正确的alert()
,但附加它只是以防万一:
[...]
response.setContentType("text/html;charset=utf-8");
PrintWriter out;
try {
out = response.getWriter();
out.println("something");
out.flush();
out.close();
}
catch (IOException e) {
// treatment
}
[...]
我真的很感激任何帮助,因为它快把我逼疯了。非常感谢。
println()
方法在打印字符串的末尾添加一个新的行字符,而您在没有它的情况下比较它。试着
out.print("something");