scala - 找不到 Scala Play 路由操作
问题描述
我不明白为什么这不起作用。
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Serve index page from public directory
GET / controllers.HomeController.index
GET /index controllers.FrontendController.index
# An example route (Prefix all API routes with apiPrefix defined in application.conf)
GET /api/summary controllers.HomeController.appSummary
POST /api/getplt/:args controllers.UploadController.getPlt(args)# Serve static assets under public directory
GET /*file controllers.FrontendController.assetOrDefault(file)
为什么它不能解决这个动作?我可以毫无问题地解决 /api/summary 。
解决方案
首先为您的资产使用以下内容:
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(file)
然后你可以assetFinder
在你的视图中使用,比如:
<script src="@assetsFinder.path("javascripts/jquery.js")" type="text/javascript"></script>
这是因为尽量避免任何相似/相同的路线,您的第一条路线和资产相关路线看起来几乎相同。
因此,要回答您的问题,要么 Play 混合了这两条路线,要么您的班级中没有index
方法。HomeController
推荐阅读
- node.js - 如何使用其中提到的用户进行随机自动回复
- go - 在结构方法中更改后指针值设置为零
- flutter - 使用 flutter_google_places 自动完成搜索不起作用?
- ktor - Ktor 自定义功能交换网址
- android - 如何将 .ipa/.apk 放在网站上,以便人们可以通过第三方安装它?
- cordova - 新 M1 mac 的 ionic cordova 本地插件错误
- node.js - 加载 mydomain.com/anyotherpage 时出现 A2 托管错误 404 的 Node.js
- r - R:使用 R 中的 latticeExtra 云调整 3DBarplot 的颜色渐变
- c# - 意外的名称参数:用户/ VSCODE
- python - Django 在课堂上访问 pk id