Stripes,GAE:如何实现其他方法处理(POST)

时间:2010-12-07 13:23:26

标签: json google-app-engine methods http-post stripes

不知道为什么这个(来自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;
}

1 个答案:

答案 0 :(得分:2)

String比较错误:

request.getMethod() == "POST"

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

"POST".equals(request.getMethod())