2

不知道为什么这个(来自 SomeActionBean.java 的附加方法)在 Google 应用引擎上不起作用?Localy 一切运行完美。知道在哪里寻找解决方案吗?

 /**
 * @return Page to display, filled with correct data
 */
@DefaultHandler
public Resolution welcome() {
    Resolution fd = new ForwardResolution(VIEW);
    HttpServletRequest request = this.ctx.getRequest();
    if(request.getMethod() == "POST") { 
        String content = getRequestContent(request);
        updateData(content);
    }else if (request.getMethod() == "GET"){
        String ct = request.getContentType();
        if(("application/json").equals(ct))
            try {
                getNotesJson(); //fill returnJson global variable
                fd = new JSONResolution(returnJson);
                //TODO Spread to other entities
            } catch (JSONException e) {
                e.printStackTrace();
            }
    }
    return fd;
}
4

1 回答 1

2

字符串比较是错误的:

request.getMethod() == "POST"

Java 字符串不是原语,因此它们应该通过equals方法进行比较:

"POST".equals(request.getMethod())
于 2010-12-08T20:10:38.153 回答