搜索
系统检测到您的用户名不符合规范:

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

浏览:475 发布日期: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月28日T07: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月28日T07: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
最佳答案
评论() 相关
后面还有条评论,
评论支持使用[code][/code]标签添加代码
您需要登录后才可以评论 登录 | 立即注册
收藏
正宗好鱼粉
积分:199 等级:LV1
热点推荐
(追記) (追記ここまで)
最新更新

我们

合作

网站

信息

ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。

AltStyle によって変換されたページ (->オリジナル) /