【发布时间】:2017-08-31 12:04:26
【问题描述】:
我会用代码解释我的问题:
首先我的应用程序(ls -R):
/康定
控制器 kantine.conf kantine.pl Kantine.pm 模板
Kantine/控制器: 餐厅.pm Sandwich.pm
Kantine/模板: cantine.html.ep
我使用命令“hypnotoad kantine.pl”在 hypnotoad 下启动它。
一切都很好
Kantine/kantine.pm :
package Kantine;
use strict;
use warnings;
use Mojo::Base 'Mojolicious';
sub startup
{
my $self = shift;
my $config = $self->plugin('Config');
my $r = $self->routes;
$r->get('/restaurant')->to('restaurant#loadData');
$r->get('/sandwich')->to('sandwich#loadData');
$r->get('/test')->to(template => 'cantine');
}
1;
Kantine/控制器/餐厅:
包控制器::餐厅;
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
sub loadData
{
my $self = shift;
$self->render('cantine');
}
1;
"curl http://127.0.0.1:3000/test" 工作正常(得到一个空白页)但 "curl http://127.0.0.1:3000/restaurant" 没有(找不到页面)。我不明白为什么!如果您发现问题所在..
谢谢!
【问题讨论】:
-
拼写错误?您在一个地方有
loadData,在另一个地方有loadDate(感谢您剪切和粘贴您的真实代码)。 -
修复它,但似乎还有更多!我也会在帖子中编辑它!我添加了一个日志文件,它告诉我“控制器“Kantine::Restaurant”不存在”,我会试着看看为什么:)
标签: perl routing mojolicious