Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play! Framework - creating simple html links

I have a website that I have made using several HTML files and one CSS file. I am currently attempting to switch over to the Play! Scala Framework. For some reason I am having a really hard time figuring out how to link one html page to another.

Right now all my html files are saved in the 'views' folder with names such as "index.scala.html", "aboutpage.scala.html" and so on. In simple HTML, to create a button link to a new page it looks something like this:

        <form action="index.html" method="get">
            <button class="navlink">Home</button>
        </form> 
        <form action="aboutpage.html" method="get">
            <button class="navlink">About Us</button>
        </form>
        <form action="publications.html" method="get">
            <button class="navlink">Publications</button>
        </form>

This does not work on Play! obviously, I think I may need to work with the Application and controllers files. How do you go about creating different pages in your website through Play!?

Thanks

like image 698
Cazs Avatar asked Feb 27 '26 10:02

Cazs


1 Answers

Check out the documentation for Reverse Routing:

Assuming you have a route like this:

GET   /about          controllers.Application.about()

You can change your HTML to this:

<form action="@routes.Application.about()" method="get">
like image 122
Todd Avatar answered Mar 01 '26 02:03

Todd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!