Any web behavior can be considered to be an operation of a module, and the system will analyze the modules and operations to be performed according to the current URL. This analytical work is implemented by the URL scheduler, which is built into the dispatcher class to complete the dispatch. In the dispatcher scheduler, it is based on the
Http://servername/appName/moduleName/actionName/params
To get the currently executing project (appName), module (modulename), and operation (ActionName), in some cases appName can be unwanted (usually the homepage of the site, because the project name can be specified in the entry file, in which case AppName will be replaced by the import file). Under a more complex scenario, groupings (groupname) may also appear.
Each module is an action file, similar to what we normally call a controller, the system automatically looks for the relevant class under the Project Class Library action directory, or if it is not found, navigates to an empty module or throws an exception.
The actionname operation is a public method that first determines whether an action class exists, and if it does not exist, it continues to look for methods in the parent class, and if it does not exist, it will look for an automatically matched template file. If a template file exists, the stencil output is rendered directly.
Therefore, an important process in application development is to define specific operations for different modules. An application may not need to define a model class if it does not need to interact with the database, but the action controller must be defined. The definition of an action controller is very simple, as long as it inherits the action base class, for example: Microfiber cloth
Copy Code code as follows:
Class Useraction extends action{
}
If we are going to execute the following URL
Http://servername/index.php/User/add
You need to add an Add method to it, such as
Collapse PHP code copy content to clipboard
Copy Code code as follows:
Class Useraction extends action{
Define an Add action method, note that the action method does not require any arguments
Public function Add () {
The logical implementation of the Add Operation method
... bath Rug
$this->display (); Output Template page
}
}
The action method must be defined as a public type or an error will be presented. Also note that the name of the action method is not duplicated with the built-in action class method. The system automatically locates the template file for the current operation, and the default template file should be in the tpl\default\user\add.html below the project directory.