user2627953
user2627953

Reputation: 67

Is it possible to use an html page as a view in play framework 2?

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?

Upvotes: 5

Views: 4332

Answers (1)

ndeverge
ndeverge

Reputation: 21564

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

Upvotes: 14

Related Questions