I am fairly new to Play 2.0 - I try searching for samples but always keep on getting Scala templates as the view for directing the content to, is it possible to just use a non Scala based, pure html file as a view? How do you ask the Controller's action method to direct it to that html file?
A type safe template engine based on Scala Play comes with Twirl, a powerful Scala-based template engine, whose design was inspired by ASP.NET Razor. Specifically it is: compact, expressive, and fluid: it minimizes the number of characters and keystrokes required in a file, and enables a fast, fluid coding workflow.
Play is a high-productivity web application framework for programming languages whose code is compiled and run on the JVM, mainly Java and Scala. It integrates the components and APIs we need for modern web application development.
A play application follows the MVC architectural pattern applied to the Web architecture. This pattern splits the application into separate layers: the Presentation layer and the Model layer. The Presentation layer is further split into a View and a Controller layer.
Play Framework makes it easy to build web applications with Java & Scala. Play is based on a lightweight, stateless, web-friendly architecture. Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.
First, put your HTML files in the public
folder, for example:
public
|
├── html
|
└── hello.html
And then you can serve static HTML files using several ways with the Assets controller:
Either by refering to the file directly in the Url: http://localhost:9000/assets/html/hello.html
Either by using the routes
file to map an Url to your file. In the routes
file, add:
GET /hello controllers.Assets.at(path="/public", file="html/hello.html")
Then access the Html using http://localhost:9000/hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With