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