在开发服务器中出现的错误:
[info] *** Request 2 (0.000/s) [681] [Thu Dec 12 21:05:39 2013] ***
[debug] Path is "homescreen"
[debug] "GET" request for "homescreen" from "192.168.1.100"
[debug] Rendering template "homescreen/homescreen.tt2"
[error] Couldn't render template "homescreen/homescreen.tt2: file error - homescreen/homescreen.tt2: not found"
[error] Couldn't render template "homescreen/homescreen.tt2: file error - homescreen/homescreen.tt2: not found"
[debug] Response Code: 500; Content-Type: text/html; charset=utf-8; Content-Length: 14312
[info] Request took 0.033915s (29.485/s)
.------------------------------------------------------------+-----------.
| Action | Time |
+------------------------------------------------------------+-----------+
| /homescreen | 0.000341s |
| /end | 0.014055s |
| -> Myproject::View::HTML->process | 0.013049s |
'------------------------------------------------------------+-----------'
我在做什么:
我有以下几点:
package Myproject::Controller::Homescreen;
use strict;
use warnings;
use parent 'Catalyst::Controller';
use Data::Dumper;
use JSON;
__PACKAGE__->config->{namespace} = '';
sub homescreen :Path('/homescreen') :Args(0) {
my ( $self, $c ) = @_;
print STDERR "IN THE HOMESCREEN ACTION\n";
$c->stash({template => 'homescreen/homescreen.tt2',
title => 'Home Screen'
});
}
我有以下几点:
package Myproject::View::HTML;
use Moose;
use namespace::autoclean;
extends 'Catalyst::View::TT';
__PACKAGE__->config({
#Changed default TT extension to TT2
TEMPLATE_EXTENSION => '.tt2',
render_die => 1,
});
我有以下几点:
__PACKAGE__->config(
name => 'Myproject',
# Disable deprecated behavior needed by old applications
disable_component_resolution_regex_fallback => 1,
#enable_catalyst_header => 1, # Send X-Catalyst header
);
__PACKAGE__->config(
#Configure the view
'View::HMTL' => {
#Set the location for TT files
INCLUDE_PATH => [
__PACKAGE__->path_to( 'root', 'src' ),
],
},
);
# Start the application
__PACKAGE__->setup();
然后我有一个包含所有html代码的catalyst目录
Controller/Homescreen.pm
(最终它将使用模板工具包,但目前它是纯html和javscript代码,我知道这很好)。在浏览器的“应用程序”页上出现的错误是:
Couldn't render template "homescreen/homescreen.tt2: file error - homescreen/homescreen.tt2: not found"
我试过在html.pm视图中使用
View/HTML.pm
来帮助调试,但似乎没有得到任何额外的输出。我可能忽略了一些很明显的东西,但我不知道是什么。
更新
我刚刚在浏览器调试屏幕的
lib/Myproject.pm
部分注意到以下内容:配置
do {
my $a = {
"Action::RenderView" => {
ignore_classes => [
"DBIx::Class::ResultSource::Table",
"DBIx::Class::ResultSourceHandle",
"DateTime",
],
scrubber_func => sub { ... },
},
"disable_component_resolution_regex_fallback" => 1,
"home" => "/home/fred/Myproject",
"name" => "Myproject",
"Plugin::ConfigLoader" => {},
"Plugin::Static::Simple" => {
debug => 1,
dirs => [],
ignore_dirs => [],
ignore_extensions => ["tmpl", "tt", "tt2", "html", "xhtml"], <---- IS THIS SIGNIFICANT AT ALL?
include_path => [
bless({
dirs => ["", "home", "fred", "Myproject", "root"],
file_spec_class => undef,
volume => "",
}, "Path::Class::Dir"),
],
mime_types => {},
mime_types_obj => bless({}, "MIME::Types"),
no_logs => 1,
},
"root" => 'fix',
"stacktrace" => { context => 3, verbose => 0 },
"static" => 'fix',
"View::HMTL" => {
INCLUDE_PATH => [
bless({
dirs => ["", "home", "fred", "Myproject", "root", "src"],
file_spec_class => undef,
volume => "",
}, "Path::Class::Dir"),
],
},
};
$a->{"root"} = $a->{"Plugin::Static::Simple"}{include_path}[0];
$a->{"static"} = $a->{"Plugin::Static::Simple"};
$a;
}
我认为这意味着它忽略了我的模板文件,因为它有
root/src/homescreen/homescreen.tt2
文件扩展名?但是,我没有在Catalyst项目的任何地方设置这个
DEBUG => 'undef'
属性?这是我问题的原因还是完全无关的? 最佳答案
看起来你的配置没有生效。尝试将模板放入root/homescreen/homescreen.tt2
而不是root/src/homescreen/homescreen.tt2
,Catalyst会找到它。
啊,lib/myproject.pm中有一个输入错误:
__PACKAGE__->config(
#Configure the view
'View::HMTL' => {
改为尝试
'View::HTML'
(注意您有HMTL
-拼写错误)。