0
我可以做一个没有任何问题的GET。 当用POST请求尝试它,我得到这个消息:用于Java的Restlet框架的POST
内部服务器错误
服务器遇到阻止它完成请求的意外情况
我用它测试适用于Chrome的简单REST客户端扩展程序,但在实际应用程序中可以看到相同的消息。
这是我的帖子:
@Post
public StringRepresentation pepe(Representation entity) {
StringRepresentation result = this.users();
// Parse the given representation and retrieve data
Form form = new Form(entity);
String action = form.getFirstValue("action");
if(action.equals("add")){
//nothing
}
Db.closeConnection();
return result;
}
这是我@Get正常工作:
@Get
public StringRepresentation pepe() {
String action = getQuery().getValues("action");
StringRepresentation result = null;
result = this.users();
Db.closeConnection();
return result;
}
而且有趣的是:每当我删除的条件if(action.equals("add")){
,(这是空的里面)开机自检正常工作。 这将工作:
@Post
public StringRepresentation pepe(Representation entity) {
StringRepresentation result = this.users();
// Parse the given representation and retrieve data
Form form = new Form(entity);
String action = form.getFirstValue("action");
Db.closeConnection();
return result;
}
这是怎么回事?看起来很随意!
检查你的“行动”变量不为空。你可能有一个你没有看到的NullPointerException。 – Claudio 2014-09-26 15:41:46
是的,你是对的。 – Alvaro 2014-09-26 16:15:23