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

时间:2016-01-29 15:12:22

标签: restlet

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

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

如果我使用.../page/index.html访问该服务,则该页面将显示在浏览器中。但.../page.../page/的调用会导致“未找到”错误页面。

如何将index.html设为默认文件?

1 个答案:

答案 0 :(得分:1)

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

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

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

希望它可以帮到你, 亨利

相关问题