【问题标题】:Where the statusFiles should be saved?statusFiles 应该保存在哪里?
【发布时间】:2017-10-30 18:11:39
【问题描述】:

here 所述,我尝试将Status Files 与以下代码一起使用:

install(StatusPages) {
    statusFile(HttpStatusCode.NotFound, HttpStatusCode.Unauthorized, filePattern = "#.html")
}

并将文件保存如下:

但是运行之后,我得到了标准的 404 错误,这意味着文件看不到,我需要添加一些东西,还是我将它们保存在错误的位置?

【问题讨论】:

    标签: kotlin ktor


    【解决方案1】:

    它看起来像 statusFiles() 做了一个 resolveResource(path),所以它正在查看:src/main/resources/ 并且为了使其理解/查看位于 resources 文件夹内的 statusFiles 文件夹, filePattern 需要调小点才能反映,所以正确的代码是:

    statusFile(HttpStatusCode.NotFound, HttpStatusCode.Unauthorized, filePattern = "statusFiles/#.html")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多