scala - Play Framework 路由在 URI 问题中包含“post”字样
问题描述
我有一个返回文件的播放端点,它看起来像这样:
def exportContainerPostCalculations(id: Long): Action[AnyContent] = Action.async { implicit request =>
containerExporter.exportContainerPostCalculationsToCsv(id).map {
res =>
Ok.sendFile(new File(res), inline=true).withHeaders(CACHE_CONTROL -> "no-cache", CONTENT_DISPOSITION->s"attachment; filename=${res}", CONTENT_TYPE->"application/x-download");
}
}
我有意将 CACHE_CONTROL 设置为“无缓存”,因为我希望在每次服务调用时生成新文件。我最初创建的端点看起来像这样:
GET /api/export/container/postcalculations/:id controllers.ExportController.exportContainerPostCalculations(id: Long)
然而,这并没有按预期工作。它总是从缓存返回文件并且使用默认响应头,所以“缓存控制”总是设置为“max-age=3600”。
将端点重命名为:
GET /api/export/container/finalcalculations/:id controllers.ExportController.exportContainerPostCalculations(id: Long)
我试图在 Play 文档中找到任何可以解释为什么在路由 URI 中使用“post”会导致这种意外行为的内容,但找不到任何相关内容。我想知道这是否只是 Play 框架中的一个错误,还是我从文档中遗漏了一些东西。
解决方案
推荐阅读
- javascript - 生成带有部分样式的文本?
- google-sheets - 为什么这个 Google 表格连接公式会给我奇怪的结果?
- python - 计算列表python的嵌套列表的元素
- dataweave - 如何在dataweave中对多列进行分组
- r - 如何在 R 中正确接收来自 pdf 的文本?
- c - 我如何将限制设置为变量
- ios - 如何快速测试缓存的响应?
- html - Hugo - 获取视频标题并将其转换为 URL
- .net - 在 Angular 中实现 JWT 访问令牌后从 API 获取列表时出现 401 错误
- html - 如何在其他内容上显示登录页面并在显示登录页面时删除滚动条?