新人求助-关于controller映射视图的问题

浏览:462 发布日期:2017/12/28 分类:ThinkPHP5专区
各位大神好!我昨天碰到一个奇怪的问题。就是写了一个student小例子做测试时发现新增的几个方法不能自动映射视图。除了index方法,其余的方法都不行。这是什么原因导致,runtime的文件缓存删除了一遍也没用。<?php
namespace app\index\controller;

use app\index\model\Classed;
use app\index\model\Student;
use think\Controller;

class StudentController extends Controller
{

    public function index()
    {
        $studnet = new Student();
        $studnets = $studnet->all();
        $this->assign("students", $studnets);
        return $this->fetch();
    }

    public function create()
    {
        $classed = Classed::all();
        
        $this->assign("classed", $classed);
        
        $this->fetch();
    }

    public function create1()
    {
        $this->fetch();
    }

    public function wangzhijun()
    {
        $this->fetch();
    }

    public function save()
    {
        $name = input("name");
        $age = input("age");
        $email = input("email");
        $classId = input("classId");
        $studnet = new Student();
        $result = $studnet->save([
            "name" => $name,
            "age" => $age,
            "email" => $email,
            "classId" => $classId
        ]);
        if ($result) {
            $this->success("创建成果", 'Student/index');
        }
    }

    public function edit()
    {}
}
下面是能访问的日志:
---------------------------------------------------------------
[ 2017-12-28T07:35:04+08:00 ] 127.0.0.1 GET /school/public/index.php/index/student/index.html
[ info ] 127.0.0.1/school/public/index.php/index/student/index.html [运行时间:0.062003s][吞吐率:16.13req/s] [内存消耗:1,977.34kb] [文件加载:46]
[ info ] [ LANG ] D:\WWW\school\thinkphp\lang\zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'index',
1 => 'student',
2 => 'index',
),
)
[ info ] [ HEADER ] array (
'cookie' => 'thinkphp_show_page_trace=0|0',
'accept-language' => 'zh-CN,zh;q=0.9',
'accept-encoding' => 'gzip, deflate, br',
'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'upgrade-insecure-requests' => '1',
'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
'connection' => 'close',
'host' => '127.0.0.1',
)
[ info ] [ PARAM ] array (
)
[ info ] [ RUN ] app\index\controller\StudentController->index[ D:\WWW\school\application\index\controller\StudentController.php ]
[ info ] [ DB ] INIT mysql
[ info ] [ VIEW ] D:\WWW\school\public/../application/index\view\student\index.html [ array (
0 => 'students',
) ]
[ info ] [ LOG ] INIT File
[ sql ] [ DB ] CONNECT:[ UseTime:0.013001s ] mysql:host=127.0.0.1;dbname=test;charset=utf8
[ sql ] [ SQL ] SHOW COLUMNS FROM `student` [ RunTime:0.009001s ]
[ sql ] [ SQL ] SELECT * FROM `student` [ RunTime:0.001000s ]

下面是不能访问的日志:
---------------------------------------------------------------
[ 2017-12-28T07:27:54+08:00 ] 127.0.0.1 GET /school/public/index.php/index/student/wangzhijun
[ info ] 127.0.0.1/school/public/index.php/index/student/wangzhijun [运行时间:0.022002s][吞吐率:45.45req/s] [内存消耗:1,115.13kb] [文件加载:38]
[ info ] [ LANG ] D:\WWW\school\thinkphp\lang\zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'index',
1 => 'student',
2 => 'wangzhijun',
),
)
[ info ] [ HEADER ] array (
'cookie' => 'thinkphp_show_page_trace=0|0',
'accept-language' => 'zh-CN,zh;q=0.9',
'accept-encoding' => 'gzip, deflate, br',
'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'upgrade-insecure-requests' => '1',
'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36',
'cache-control' => 'max-age=0',
'connection' => 'close',
'host' => '127.0.0.1',
)
[ info ] [ PARAM ] array (
)
[ info ] [ RUN ] app\index\controller\StudentController->wangzhijun[ D:\WWW\school\application\index\controller\StudentController.php ]
[ info ] [ VIEW ] ewangzhijun.html [ array (
) ]
[ info ] [ LOG ] INIT File
最佳答案
评论( 相关
后面还有条评论,点击查看>>