上到的Restlet資源的每個請求,我看到了谷歌應用程序引擎日誌以下日誌爲什麼的Restlet GAE上說,組件爲空
21:38:50.059 javax.servlet.ServletContext log: ExampleAPIs: [Restlet] ServerServlet: component class is null
21:38:51.568 javax.servlet.ServletContext log: ExampleAPIs: [Restlet] Attaching application: [email protected] to URI: /example/v1
爲什麼它說Component爲null? 我同意我沒有定義組件,而是使用ServerResources並將它們映射到Application類中的路由器。 但是,這是如何按照Restlet GAE Edition文檔完成的。
的佈線路徑應用類
public Example extends Application {
@Override
public Restlet createInboundRoot() {
router = new Router(getContext());
CorsService corsService = new CorsService();
corsService.setAllowedOrigins(new HashSet<String>(Arrays.asList("http://example.com")));
corsService.setAllowedCredentials(true);
getServices().add(corsService);
router.attach("/xyz", XYZ.class);
}
}
服務器資源負責處理,並返回一個JSON表示
public class XYZ extends ServerResource {
private static final Logger logger = Logger.getLogger("API:Xyz");
@Get(":json")
public Representation handleGetRequest() {
..
return new JsonRepresentation("{\"code\": 4008, \"description\": \"Something blah something\"}");
}
}
有什麼我做錯了嗎?
是的,我做到了。我跟着它的書。有趣的是我正在運行它沒有問題,但這些日誌嚇跑了我 – Atrix1987