加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – Mojolicious lite如何将未找到和服务器错误页面重定向到

发布时间:2020-12-15 21:59:19 所属栏目:大数据 来源:网络整理
导读:如何将未找到的用户定义的错误页面和服务器错误页面重定向到用户定义页面Mojolicious lite 解决方法 您可以在liteapp末尾为自定义页面添加名为exception.html.ep或not_found.html.ep的模板. 例如: use Mojolicious::Lite;get '/' = sub { my $self = shift;
如何将未找到的用户定义的错误页面和服务器错误页面重定向到用户定义页面Mojolicious lite

解决方法

您可以在liteapp末尾为自定义页面添加名为exception.html.ep或not_found.html.ep的模板.

例如:

use Mojolicious::Lite;
get '/' => sub {
    my $self = shift;
    $self->render(text => "Hello.");
};
app->start;

__DATA__
@@ not_found.html.ep
<!DOCTYPE html>
<html>
  <head><title>Page not found</title></head>
  <body>Page not found <%= $status %></body>
</html>

有关参考,请参阅Mojolicious rendering guide.

The renderer will always try to find exception.$mode.$format.* or not_found.$mode.$format.* before falling back to the built-in default templates.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读