我在使这些 ReSTLet 服务器资源正常工作时遇到了一些麻烦:
private static final String ROOT_URI = "/rest/";
@Override
public Restlet createInboundRoot() {
Router router = new Router(getContext());
Directory directory = new Directory(getContext(), "war:///doc");
directory.setIndexName("app.html");
router.attach(ROOT_URI + "files", GaeFilesServerResource.class);
router.attach(ROOT_URI + "files/{file_id}", GaeFileServerResource.class);
router.attach("/gwtapp/", directory); // This is the only one that works
router.attach("/", RootServerResource.class);
return router;
}
正如评论中所述,路线/gwtapp/是唯一有效的路线。访问 http://localhost:8080/gwtapp/
转发到 http://localhost:8080/gwtapp/app.html
这是正确的。
问题是:
我想知道为什么 /
和 /rest/
下的那些在这种情况下不起作用?
最佳答案
解决方案是附加:
router.attachDefault(RootServerResource.class);
相反。
关于java - ReSTLet 路由不适用于路由中的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34598062/