Munkhbat Mygmarsuren
Munkhbat Mygmarsuren

Reputation: 113

How can load sample html page on index page in Play framework?

here is my piece code:

 <div id="account"><a href="@routes.Contacts.blank()">Contact</a></div>` 

instead of it, i use above code

<div id="account"><a href="account.html">Contact</a></div>

So, i want to direct load static html page on index page.
Please help me. Tank's

Upvotes: 1

Views: 2094

Answers (2)

James Ward
James Ward

Reputation: 29433

You can map the index page to a static file by creating a route in your conf/routes file, like:

GET     /                           controllers.Assets.at(path="/public", file="index.html")
GET     /*file                      controllers.Assets.at(path="/public", file)

Upvotes: 10

biesior
biesior

Reputation: 55798

You need to create a route in conf/routes file pointing some action ie:

GET  /contact    controllers.Contacts.blank

so then you can build links with typed routes (strongly recommended):

<a href="@routes.Contacts.blank()">Contact</a>

or you can write it as a hardcoded path. What's important - it MUST fit second part of your route in the final HTML code

You can also write routes with *.html 'extension' BUT it's completely unnecessary as browsers recognizes response by its header not the path!

GET  /contact.html    controllers.Contacts.blank

Upvotes: 0

Related Questions