只能说,再一次被大小写坑了,作为菜鸟的我。。。
warming:如果系统提示XXX not found , 多次查阅无果,请尝试把首字母改为大写。。。
问题:controller类型文件太多,需要归类。。。
直接上好了。。。
│ ├─MyApp │ │ │ Test.pm │ │ │ │ │ ├─Controller │ │ │ Example.pm │ │ │ Page.pm │ │ │ Postpage.pm │ │ │ │ │ └─Test │ │ Aaa.pm │ │
上面是目录布局
Test.pm
package MyApp::Test; use Mojo::Base 'Mojolicious::Controller'; 1;
Aaa.pm
package MyApp::Test::Aaa; use Mojo::Base 'Mojolicious::Controller'; # This action will render a template sub tta { my $self = shift; $self->stash(msg => 'hello world!'); # Render template "Test/Aaa/tta.html.ep" with message $self->render(); } 1;
templates\test\aaa\tta.html.ep
% layout 'default'; % title 'Welcome'; <h2><%= $msg %></h2>
最后还有一个 route
$r->get('/aa')->to('Test::Aaa#tta');
转载于:https://blog.51cto.com/rzl01/1733957