我會解釋我的問題與代碼:mojolicious應用conrollers沒有按牛逼呈現模板,他們應該呈現
第一我的應用程序(LS-R): /Kantine 控制器kantine.conf kantine.pl Kantine .pm的模板
Kantine /控制器: Restaurant.pm Sandwich.pm
Kantine /模板: cantine.html.ep
我用hypnotoad命令「hypnotoad kantine.pl」啓動它。 一切都很好
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;
「捲曲http://127.0.0.1:3000/test」工作正常(有一個空白頁),但「蜷縮http://127.0.0.1:3000/restaurant」沒有(得到找不到網頁)。我不明白爲什麼!如果你看到有什麼問題..
Thx!
拼寫錯誤?你在一個地方有'loadData',在另一個地方有'loadDate'(謝謝你剪切和粘貼你的真實代碼)。 – mob
修復它,但似乎有更多的東西!我將在帖子中編輯它也thx!我添加一個日誌文件,它告訴我,「控制器」Kantine ::餐廳「不存在」,我會試着看看爲什麼:) –