Follow Vamei-01 Beginner Play

Source: Internet
Author: User
Tags http request

Hey. Hello everyone. As the company used the play framework, to get started as soon as possible. I started a lot of help degree Niang. However, many of the documents are written too simplified, and most of them are in English. Oh,my God. The crowd sought him 1100 degrees, but it was in the dim light. Finally, he read the blog of the Vamei Great God (Http://www.cnblogs.com/vamei). A little shallow cognition of the Play,mark down.

1. I am the environment configuration under the Windows environment

First go to the play website to download the version you need, I use the play2.2.1 version of the

After downloading the play-2.2.1.zip, unzip it and put it in the location you specified. My D:\soft\play-2.2.1, and then configure environment variables, which can be added in the environment variables in the properties of the computer, or by CMD.

The configuration environment variables under CMD are described here. 1, setx play_home "D:\soft\play-2.2.1", 2, Setx Path "%play_home%";

OK configure environment variables successfully, you can test under. Enter play under CMD


Congratulation, you have succeeded.

2. Let's have a play.

Under CMD, we switch to E:\study\playSecond (you can switch to your own directory) under the directory.

Try play new test. Ok


The creation succeeds, then goes to the test directory, executes play, and then executes Eclipse. OK, you can import it into our Eclipse editor.



Then we'll import eclipse to see the Mystery Play Project catalogue.


The most important folder above is the app, which contains the MVC definition of the project. Play uses the MVC Architecture (Model-view-control). The new project has created controllers and views, including controller and view templates. If necessary, you can create a models folder under the app to define the data model.
Application.conf contains the individual setup parameters for the project.
The routes records the correspondence between the URL request and the controller. When an HTTP request enters, play will invoke the specific controller action based on the file's settings.

Execute play bar, run in test directory


In the browser input http://localhost:9000/see the following screen, you have succeeded, is not very simple.


3, the Great God quotes:

The main function of the play framework is to dynamically generate HTTP responses. The HTTP protocol works in the form of a request-response (Request-response). For an introduction to HTTP communication, refer to the HTTP protocol.
Play is an MVC architecture that generates responses in steps, with each step being responsible for different modules. A simple page above is generated by the following process:


The black font in the figure indicates the specific file in which these features are located in the project.
Routes is responsible for directing the URL to the correct action. The action is the core of the generated HTTP response. An action passes a series of operations, producing a response. Controller controllers are just a collection of action. In Java programming, action is a method of the Controller class. The action response can be passed to a view, such as the index.scala.html above, for better control of the display effect. The final result is an HTTP response, which is the page we see.
By personalizing the above process, we can design a richer network application.

Continuous operation

The on-play server can be run continuously. When you install play on a target server, such as the cloud, at the root of the play project, use: Play start
To run the server continuously. You can then press ctrl-d to return to the command line. The play does not depend on the shell at this time, and even if you log out of the server, play will continue to run.
Run with a different port: Play "start-dhttp.port=8080"
Stop running. To switch to the root of the project, use the command: Play stop

Thank Vamei, I am winter. Come on. I believe I can.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.