http://www.playframework.org/documentation/1.2.4/main The MVC application modelA Play application follows the MVC architectural pattern applied to the web architecture. This pattern splits the application into separate layers: the Presentation layer and the Model layer. The Presentation layer is further split into a View and a Controller layer.
In a Play application these three layers are defined in the app/controllersA Controller is a Java class where each public, static, method is an action. An action is a Java entry point invoked when an HTTP Request is received. The Java code from the Controller class isn’t really object oriented: it’s mainly procedural code. The action method extracts relevant data from the HTTP Request, reads or updates the model objects, and sends back a result which is wrapped into an HTTP Response. app/modelsThe domain model object layer is a set of Java classes using all the object-oriented features available from the Java language. It contains data structures and operations on which the application operates. Whenever model objects need to be saved to persistent storage, they may contain some glue artifacts like JPA annotations or SQL statements. app/viewsMost of the application views are generated using an efficient templating system provided by Play. The Controller gets some interesting data from the model layer, and then applies a template to decorate these objects. This package contains HTML, XML, JSON or other template files with special directives used to dynamically generate the model representation. The request life cycleThe Play framework is fully stateless and only request/response-oriented. All HTTP Requests follow the same path:
The following diagram summarizes the HTTP Request path: |
02.快速入門 >