The difference between Render,redirect,dispatch in cakephp

Source: Internet
Author: User
The difference between Render,redirect,dispatch in cakephp
http://blog.csdn.net/kunshan_shenbin/article/details/6221219
In cakephp, jump through three commonly used functions, render,redirect,dispatch
1. Render function
Public function render ($action = null, $layout = NULL, $file = NULL)
Render
String $action
String $layout
String $file
Render rendered view, you may not use this method often, because the Render method is called automatically at the end of the controller action, outputting the view as the action name command. At the same time, you can use this method to output the view in any position in the controller logic, if you want to jump to other pages in the current controller if the logic is called in the controller, for example:
After deletion succeeds in the delete function, jump to the list page index. Can write like this
Public Function Delete () {
$this->index ();
$this->render (null, NULL, ' Index ');
}
2. redirect Function
redirect
String $url
User redirection, in this way, tells your users where they should continue to visit. The URL parameter passed in here can be either a cake internal URL or a full URL (http://). )。 This method is to send the URL to the browse and then request again.
3. Dispatch function
The dispatch function is in the dispatcher class and he has
$Dispatcher->dispatch ($url);
Here the scheduler will parse the URL to get the relevant parameters (which will be called to more actions including route to parse the URL) forwarded to the corresponding controller, and finally transfer control to the method in the relevant controller. This method is mainly to jump to other controllers, the same controller jumps with render.
Note: To use dispatch jump when the end of the time to call exit;
App::import (' Core ', Array (' Dispatcher ')); $dispatcher = new Dispatcher (); $dispatcher->dispatch ($this, Request, $this->response,array ("Controller" = "admins", "action" = "site");        Exit ();
  • 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.