Play! Framework - creating simple html links

2019-04-13 06:43发布

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

1条回答
【Aperson】
2楼-- · 2019-04-13 07:23

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">
查看更多
登录 后发表回答