Welcome to Play
Congratulations, you’ve just created a new Play application. This page will help you with the next few steps.
You’re using Play 2.7.3
Why do you see this page?
The conf/routes
file defines a route that tells Play to invoke the HomeController.index
action
whenever a browser requests the /
URI using the GET method:
# Home page
GET / controllers.HomeController.index
Play has invoked the controllers.HomeController.index
method:
public Result index() {
return ok(index.render("Your new application is ready."));
}
An action method handles the incoming HTTP request, and returns the HTTP result to send back to the web client.
Here we send a 200 OK
response, using a template to fill its content.
The template is defined in the app/views/index.scala.html
file and compiled as a standard Java class.
@(message: String)
@main("Welcome to Play") {
@play20.welcome(message, style = "Java")
}
The first line of the template defines the function signature. Here it just takes a single String
parameter.
Then this template calls another function defined in app/views/main.scala.html
which displays the HTML layout, and another
function that displays this welcome message. You can freely add any HTML fragment mixed with Scala code in this file.
Note that Scala is fully compatible with Java, so if you don’t know Scala don’t panic, a Scala statement is very similar to a Java one.
You can read more about Twirl, the template language used by Play, and how Play handles actions.
Need more info on the console?
For more information on the various commands you can run on Play, i.e. running tests and packaging applications for production, see Using the Play console.
Need to set up an IDE?
You can start hacking your application right now using any text editor. Any changes will be automatically reloaded at each page refresh, including modifications made to Scala source files.
If you want to set-up your application in IntelliJ IDEA or any other Java IDE, check the Setting up your preferred IDE page.
Need more documentation?
Play documentation is available at https://www.playframework.com/documentation.
Play comes with lots of example templates showcasing various bits of Play functionality at https://www.playframework.com/download#examples.
Need more help?
Play questions are asked and answered on Stackoverflow using the "playframework" tag: https://stackoverflow.com/questions/tagged/playframework
The Discuss Play Forum is where Play users come to seek help, announce projects, and discuss issues and new features.
Gitter is a real time chat channel, like IRC. The playframework/playframework channel is used by Play users to discuss the ins and outs of writing great Play applications.