Rayas, GAE: Cómo poner en práctica otros métodos de manipulación (POST)
-
09-10-2019 - |
Pregunta
No sabe por qué esto (método adjunto de SomeActionBean.java) no está disponible en el motor de aplicación de Google? Localmente todo funciona perfecto. ¿Alguna idea de dónde buscar solución?
/**
* @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;
}
Solución
The String compares are wrong:
request.getMethod() == "POST"
Java Strings are not primitives thus they should be compared by equals method:
"POST".equals(request.getMethod())
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow