dhtmlxform.send响应在警报提示中正确显示,但字符串比较不起作用

时间:2014-05-21 12:08:13

标签: java javascript jsp struts dhtmlx

也许这是一个愚蠢的错误,对我来说仍然是隐形的,但我只是看不到它。

[...]
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    
}
[...]

我真的很感激任何帮助,因为它让我发疯。 非常感谢你。

1 个答案:

答案 0 :(得分:0)

println()方法在打印字符串的末尾添加一个新行字符,而在没有它的情况下进行比较。尝试

out.print("something");