Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
164 lines (143 loc) · 6.12 KB
/
Copy pathindex.html
File metadata and controls
164 lines (143 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<html lang="en">
<head>
<title>Play Java Tutorial</title>
</head>
<body>
<div>
<h2>Welcome to Play %PLAY_VERSION%</h2>
<p>
<em>Congratulations, you’ve just created a new Play application!</em>
</p>
<p>
<a href="http://www.playframework.com/">Play Framework</a> makes it easy to build web applications with Java & Scala. Play is based on a lightweight, stateless, web-friendly architecture. Built on <a href="http://akka.io">Akka</a>, Play provides predictable and minimal resource consumption for highly-scalable applications.
</p>
<p>
This tutorial introduces you to the essentials of your new Play application.
</p>
</div>
<div>
<h2>Run Your Application</h2>
<p>
Before we go any further, let's run the application.
</p>
<ol>
<li>Go to the <a href="#run" class="shortcut">Run</a> page.</li>
<li>Click <em>Start</em> to start the application (if needed).</li>
<li>View the running application at <a href="http://localhost:9000">http://localhost:9000</a>.</li>
</ol>
</div>
<div>
<h2>Actions, Controllers and Results</h2>
<p>
In Play, web requests are handled by actions.
</p>
<p>
Actions process each request, perform any work that's needed, and then return a <code>Result</code>. Actions are grouped into <code>Controller</code>s.
</p>
<p>
This application defines a <code>Controller</code> in <a href="#code/app/controllers/Application.java" class="shortcut">app/controllers/Application.java</a>. <code>Application</code>'s <code>index</code> method is an action which returns a <code>Result</code> of <code>ok</code>.
</p>
<p>
<a href="%PLAY_DOCS_URL%/JavaActions">Learn about Actions, Controllers and Results</a>
<p>
</div>
<div>
<h2>HTTP Routing</h2>
<p>
Play routes incoming HTTP requests to their actions. The mappings between requests and actions are defined in <a href="#code/conf/routes" class="shortcut">conf/routes</a>.
</p>
<p>
<a href="%PLAY_DOCS_URL%/JavaRouting">Learn about HTTP Routing</a>
<p>
</div>
<div>
<h2>Twirl Templates</h2>
<p>
This application renders HTML using Twirl templates.
</p>
<p>
The templates are defined in the <a href="#code/app/views" class="shortcut">app/views</a> directory. Each Twirl template is compiled into a Scala object which can be called from Java or Scala code.
</p>
<p>
The <code>index.render(...)</code> code within <a href="#code/app/controllers/Application.java" class="shortcut">Application.java</a> calls the <a href="#code/app/views" class="shortcut">app/views/index.scala.html</a> template.
</p>
<p>
Twirl ships with Play by default but you can use other view technologies too. For example, you could use Handlebars instead of Twirl.
</p>
<p>
<a href="%PLAY_DOCS_URL%/JavaTemplates">Learn about Twirl Templates</a>
<p>
</div>
<div>
<h2>Static Assets</h2>
<p>
Your application automatically serves static resources such as JavaScript, CSS and images.
</p>
<p>
Normal assets live in the <a href="#code/public" class="shortcut">public</a> folder.
</p>
<p>
Assets that need compilation, such as <a href="http://coffeescript.org/">CoffeeScript</a> and <a href="http://lesscss.org/">LESS</a> files, go in the <a href="#code/apps/assets" class="shortcut">app/assets</a> folder. These assets have extra processing applied to them.
</p>
<p>
Assets are served by Play's <code>Assets</code> controller. The <code>Assets</code> controller is configured in the <a href="#code/conf/routes" class="shortcut">conf/routes</a> file.
</p>
<p>
<a href="%PLAY_DOCS_URL%/Assets">Learn about Working with Assets</a>
<p>
</div>
<div>
<h2>Build System</h2>
<p>
Your Play application is built with <a href="http://www.scala-sbt.org/">sbt</a>.
</p>
<p>
Build configuration is defined in the <a href="#code/build.sbt" class="shortcut">build.sbt</a> file. You can edit this file to add new project dependencies or to change compilation settings.
</p>
<p>
Plugins extend sbt with new behavior. You can set up sbt plugins in the <a href="#code/project/plugins.sbt" class="shortcut">project/plugins.sbt</a> file. The Play sbt plugin is configured in this file. There are also separate plugins to compile assets, such as CoffeeScript and LESS.
</p>
<p>
<a href="%PLAY_DOCS_URL%/Build">Learn about the Build System</a>
<p>
</div>
<div>
<h2>Runtime Configuration</h2>
<p>
You can change your application's runtime behavior by editing <a href="#code/conf/application.conf" class="shortcut">conf/application.conf</a> file. There are lots of commented-out settings in there for you to use as a starting point.
</p>
<p>
Play uses the <a href="https://github.com/typesafehub/config#readme" target="_blank">Typesafe Config Library</a> to manage its configuration. Editing the <code>application.conf</code> file is just one of many ways that you can configure your application.
</p>
<p>
<a href="%PLAY_DOCS_URL%/Configuration">Learn about Configuration</a>
<p>
</div>
<div>
<h2>Command Line</h2>
<p>
You're probably reading this tutorial right now from within <a href="https://typesafe.com/activator">Typesafe Activator</a>'s browser UI. However, if you prefer, you can build and run your application from the command line.
</p>
<pre>$ activator ~run</pre>
<p>
You can run tests from the command line too.
</p>
<pre>$ activator ~test</pre>
<p>
<a href="%PLAY_DOCS_URL%/PlayConsole">Learn about the Play console</a>
</p>
</div>
<div>
<h2>More Information</h2>
<p>
General information about Play is available from <a href="http://www.playframework.com">playframework.com</a>.
</p>
<p>
There is documentation <a href="%PLAY_DOCS_URL">available online</a>.
</p>
<p>
You can also ask questions on <a href="http://stackoverflow.com/questions/tagged/playframework">Stack Overflow</a>.
</p>
</div>
</body>
</html>