OK、私は最初の問題の質問投稿からいくらか進歩しました。新しいシナリオはこちら
Server server = new Server(Protocol.HTTP, 8182, new TestServerApplication());
server.start()
Here's the code that's in the client
ClientResource clientResource = new ClientResource(
"http://localhost:8182/contacts/123");
次のコードは機能しません
router.attach("/contacts/123", ContactServerResource.class);
Exception in thread "main" Not Found (404) - Not Found
次のコードは機能しません
router.attach("/contacts/123", ContactServerResource.class, Router.MODE_BEST_MATCH);
Exception in thread "main" Not Found (404) - Not Found
* attachDefault を使用すると、呼び出しが適切に処理されます
// success!
router.attachDefault(ContactServerResource.class);
サーバーを使用するのではなく、別のことも試しました。
Component component = new Component();
// Add a new HTTP server listening on port 8182.
component.getServers().add(Protocol.HTTP, 8182);
// Attach the sample application.
component.getDefaultHost().attach("/contacts/123",
new TestServerApplication());
component.start();
この場合router.attach("/contacts/123", ContactServerResource.class)
、 は引き続き呼び出され、まだ機能しません。あなたはattachDefault()
それを機能させる必要があります
他に試してみることが思い浮かびません。誰にもアイデアはありますか?ありがとうございました