【问题标题】:Restlet: use "index.html" as default for serving static content using CLAP protocolRestlet:使用“index.html”作为使用 CLAP 协议提供静态内容的默认值
【发布时间】:2016-01-29 15:12:22
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: restlet


    【解决方案1】:

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

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

    好像默认值是index而不是index.html...

    希望对你有帮助 蒂埃里

    【讨论】:

    • 谢谢,/page/ 现在只有 /page 不能工作。有没有办法让它工作?
    • 这适用于我的版本 2.3.5。你用的是哪个版本?
    • 我也用 2.3.5。使用 Chrome 会失败,但 Firefox 可以。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-02
    • 2016-11-30
    • 2011-10-14
    • 2014-07-30
    • 1970-01-01
    相关资源
    最近更新 更多