application.name
の値には、どのようにしてconf/application.conf
からアクセスできますか?ビューでPlay Frameworkの設定値
答えて
あなたはそうするように、次のサンプルコードを使用することができます。
${play.configuration['application.name']}
も値を読み取るために、プレイScalaの2.3.x以降では...プレイ2用
をhttp://groups.google.com/group/play-framework/browse_thread/thread/1412ca8fc3edd22f
ありがとうございます。それは私が必要としていたものでした。 – Ryan
レコードについて:Play 2.0で変更されたものは、もう動作しません。 Play 2.0ソリューションについては、http://stackoverflow.com/questions/9857907/access-play-2-0-configuration-variables-in-application-confを参照してください。 –
の更新を参照してくださいconf/application.conf
から、次の操作を行うことができます。
import play.api.Play.current
...
current.configuration.getString("application.name")
Pの更新lay 2.5.x
Play Scala 2.5.xでは、Playオブジェクトの現在のメソッドは非推奨です。 conf/application.confから値を読み取るには、代わりにDIを使用する必要があります。その後
class MyController @Inject() (val configuration: play.api.Configuration) extends Controller
、あなたが直接あなたの方法でconfiguration
を使用することができます:
def sayMyName = Action { request =>
Ok("Your name is " + configuration.getString("application.name"))
}
また、あなたのビュートワールテンプレートでconfiguration
を使用することができます。
を注入play.api.Configuration
def sayMyNameUsingView = Action { request =>
implicit lazy val config = configuration
Ok(views.html.index())
}
は、[アクセス再生のindex.scala.html
@()(implicit val configuration:play.api.Configuration)
<html>
<body>
<h1>Your name is @configuration.getString("application.name")</h1>
</body>
</html>
- 1. Play framework:カスタムテンプレートの設定方法
- 2. Play Frameworkの設定ファイルでwar.contextを使用する方法は?
- 3. Heroku - Play Frameworkアプリでpostgresデータベースを設定できませんか?
- 4. Play/Java-framework-2.5でSwaggerを設定する
- 5. Play Framework 2.0の継続的な統合設定
- 6. スタートアップ自動テスト時にPlay Frameworkにログインする設定
- 7. (Play framework)@OrderColumnに初期データyamlを設定する
- 8. Play Frameworkの
- 9. Play 2.1 SSL設定
- 10. play framework dependecies
- 11. Play Framework Webサービスチュートリアルスケーラ
- 12. Play Framework GUID
- 13. Play FrameworkとDB2
- 14. play framework secure config
- 15. play-framework [2.0] HTTPS
- 16. GenericsとPlay Framework
- 17. Play Framework CRUD
- 18. Play Framework 2.0ビュー内の現在のアクションを見つける
- 19. OpenFiftのPlay Framework App
- 20. Playの設定変数!フレームワーク
- 21. Play Framework以外のPlay Frameworkモデルへのアクセス
- 22. Play Framework - パラメータでリダイレクトする
- 23. Play Frameworkモジュールの作成:IDE設定と他のプレイモジュールへの依存性
- 24. Entity Frameworkで既定値を設定する方法
- 25. Play Framework Scala REST DELETE
- 26. Play Framework 2レンダリングpdf
- 27. serverside highchart with play framework
- 28. Play FrameworkとScala import
- 29. Play framework 2.5 scala i18n
- 30. jquery templates with play framework
与えられた可能性のある重複するなどの暗黙的な注入さ
configuration
を送ってください! 2.0の設定変数はapplication.confにありますか?](http://stackoverflow.com/questions/9857907/access-play-2-0-configuration-variables-in-application-conf) – 030