0

我有一个链接,比如http://www.myweb.it/people/add/执行时我有关于不存在的add视图和 json 的问题:

错误:未找到 PeopleController::add() 的视图。

错误:确认您已创建文件:/var/datas/httpd/vhosts/myweb.it/demo/htdocs/0.4/app/View/elements/json.ctp

问题是在本地正确处理了导入的文件。这是整个人员控制器:

<?php
class PeopleController extends AppController {
    var $name = 'People';
    public $components = array('RequestHandler');
    public $helpers = array('Html', 'Form');

        public function add() {
        $this->autorender = false;

        if ($this->request->is('post')) {
            if ($this->Person->save($this->request->data)) {
                $this->set('return', 'I dati sono stati salvati.');
            } else {
                $this->set('return', 'Non è stato possibile salvare i dati.');
            }
        }

        $this->layout = 'void';
        $this->render('/elements/json');
    }

    public function getPeopleByName(){
        $people = $this->Person->getPeopleByName($_GET['name']);
        $this->set(array(
            'People' => $people,
            '_serialize' => array('People')
        ));
    }
}

任何的想法?

4

1 回答 1

2

我认为$this->render('/elements/json');应该是$this->render('/Elements/json');,至少如果您的元素放置在 CakePHP 的默认元素位置,即app/View/Elements.

于 2012-09-13T07:32:23.240 回答