play learning framework 001

[Contact with a project that uses the framework to write the play, I wrote little notes, I will today issue encountered little knowledge points, play down the framework for the use of finishing. After it may be a little messy, such as completion of the project, a good finish to sum up]
(previously to play framework configuration environment variable the
first to elaborate on my task today. In the content front end to query the database table 1 and show. Of course, in fact, this should be very simple, but I was a rookie, and the first use of the framework, so it is still a little ignorant of)

After Play a new project, there will be models, views, controllers three folders, just corresponds to MVC, and each type of document must also be the right place.
Since Play applications follow the MVC web application structure, it briefly talk about the MVC pattern . MVC full name is the Model View Controller, is a model (model) - view (view) - abbreviation controller (controller) is. : Create a Web application design patterns MVC is a (- - Model View Controller Model View Controller) using the MVC
Model (model) represents the core of the application (such as a database record list).
View (View) display data (database record).
Controller (controller) for input (write a database record).
E.g:

Model (model) is a portion for processing the application logic of the application data.
  Model objects are usually responsible for accessing data in the database.
View (View) is a partial processing data applications.
  Usually view is created based on the model data.
Controller (Controller) is a part of the application processing user interaction.
  Typically the controller is responsible for reading data from the view, a user input control, and the transmission data model.
(MVC model while providing full control over HTML, CSS and JavaScript)

Here Insert Picture Description
These three layers are defined in the application directory Play in the frame, in a separate package.
app / controllers
controllers are each public static method of a java class is an act. An action is calling a java entry point, receives a HTTP request. Class java code from the controller is not true object-oriented: it is the main program code. action method for extracting data from the HTTP request, to read or update the object model, and the results are packaged into the HTTP response.

app / models
domain model java class object layer is a set of object-oriented features all may be used language from java. It contains data structures and applications running operation. When the objects in the model needs to be saved to persistent storage, they may contain some glue artifacts JPA annotations or SQL statements.

app / views
most application view is a valid use of system-generated template. The controller get some interesting data from the model layer, then apply a template to decorate these objects. This package contains the HTML, XML, JSON, or other template files, which have special instructions for dynamically generating model representation.

Today, small harvest knowledge points:
1, the following is the front page shows the contents of the database. Wherein ng-if = "total == 0 " if the list ng-if = "total> 0 " is displayed if the operation is equivalent to, if the query number is 0, it displays "No display data". ng-repeat = "obj in objs " is the content of the query to loop until there is no data, which is objs (equivalent organization) database query, in the js, when you can initialize the table of data into them. = class-ng "{BG: Katex the parse error: the Expected 'the EOF', GOT '}' position AT. 4: ODD}" even line style. {{(Page ... index +. 1}} This is a number on the form.

<li class="txtCt gray" ng-if="total==0">暂无数据</li>
  <li ng-repeat="obj in objs" ng-class="{bg:$odd}" ng-if="total>0" >
  <span class="t10">{{(pageIndex-1)*pageSize+$index+1}}</span>
  <span class="t14">{{obj.col1}}</span>
  <span class="t18">{{obj.col2}}</span>
  <span class="t18">{{obj.col3}}</span>
  <span class="t18">{{obj.col4}}</span>
  <span class="t18">{{obj.col5}}</span>
  <span class="t10">

2, js page, on the background by qryList operation typically use "post", the path method of the class is the real side of the URL to access the database () of. params is both parameters.

qryList: function (index, size,searchText) {
    return $http({
     method:'post',
     url: '/XXX/XXXXXXX/方法,
     params: {
      PAGE_INDEX: index,
      PAGE_SIZE: size,
      //searchKeyWord: searchText || ''
     }
    });

3, the model layer, to define a number of fields, corresponding to the database, then the database in response to the operation. This is a simple query and display the data using the play frame.

Published 27 original articles · won praise 1 · views 1232

Guess you like

Origin blog.csdn.net/qq_40484416/article/details/93539047