Request Verifier で投稿の http 本文を取得したい場合、エンティティがリセットされ、リソース クラスで http 本文を取得しようとすると nullpointer 例外が発生します。
検証者:
JsonRepresentation jsonrep;
try {
Representation entity = request.getEntity();
jsonrep = new JsonRepresentation(entity);
//bug: entity resets when getJsonObject is being called.
JSONObject jsonobj = jsonrep.getJsonObject();
if(companyId != jsonobj.getInt("id_companies")){
return Verifier.RESULT_INVALID;
}
...
AppResource :
@Post
public Representation addApp(Representation rep) throws Exception{
//rep is null
JsonRepresentation jsonrep = new JsonRepresentation(rep);
私が電話しないとき:
JSONObject jsonobj = jsonrep.getJsonObject();
それはうまく動作します。
誰かが同じ問題に直面している、または解決策を得ていますか?
前もって感謝します!