Restlet:使用 "index.html" 作为使用 CLAP 协议提供静态内容的默认值

Restlet: use "index.html" as default for serving static content using CLAP protocol

我想将静态内容放入基于 restlet 的 Web 服务中。静态部分必须驻留在服务的 jar 中。我使用的代码是:

Directory directory = new Directory(getContext(), "clap://class/pageData"); router.attach("/page", directory);

如果我使用 .../page/index.html 访问该服务,该页面将显示在浏览器中。但是 .../page.../page/ 的调用会导致 "Not found" 错误页面。

如何使 index.html 成为默认文件?

您应该尝试在您的目录中隐式指定 indexName 属性:

Directory directory = new Directory(
     getContext(), "clap://class/pageData");
directory.setIndexName("index.html");
router.attach("/page", directory);

似乎默认值是index而不是index.html...

希望对你有帮助, 蒂埃里