Play! Framework - creating simple html links

时光怂恿深爱的人放手 提交于 2019-12-21 05:36:20

问题


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:


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">


来源:https://stackoverflow.com/questions/28035049/play-framework-creating-simple-html-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!