Domanda

Non so perché questo (metodo allegato da SomeActionBean.java) Non funziona su App Engine di Google? Localy tutto funziona perfetto. Hai idea di dove cercare la soluzione?

 /**
 * @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;
}
È stato utile?

Soluzione

Il String confronto sono sbagliato:

request.getMethod() == "POST"

Java stringhe non sono primitive così essi devono essere confrontati con è uguale a Metodo:

"POST".equals(request.getMethod())
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top