当找不到资源时,如何使Liferay 6.1.0始终重定向到404页面? [英] How do I make Liferay 6.1.0 always redirect to a 404 page when a resource isn't found?

查看:101
本文介绍了当找不到资源时,如何使Liferay 6.1.0始终重定向到404页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Liferay网站创建了一个简单的钩子.它包含一个覆盖默认Liferay 404的404.jsp.如果我在特定页面中键入内容,它将可以正常工作.例如:

I have created a simple hook for a Liferay site I have. It contains a 404.jsp that overrides the default Liferay 404. It works fine if I type in a specific page. For example:

转到 http://localhost:8080/jooky.jsp 抛出

严重程度:PWC6117:找不到文件"C%3A%5Cbundles%5Cliferay-portal-6.1.0-ce-ga1%5Cglassfish-3.1.1%5Cdomains%5Cdomain1%5Capplications%5Cliferay-portal%5Cjooky.jsp"

SEVERE: PWC6117: File "C%3A%5Cbundles%5Cliferay-portal-6.1.0-ce-ga1%5Cglassfish-3.1.1%5Cdomains%5Cdomain1%5Capplications%5Cliferay-portal%5Cjooky.jsp" not found

在我的Glassfish服务器日志中,并将我重定向到自定义的/errors/404.jsp,没有问题.

in my Glassfish server log and redirects me to my custom /errors/404.jsp without a problem.

但是,转到 http://localhost:8080/jooky 会引发不同的错误

However, going to http://localhost:8080/jooky throws a different error

INFO:14:07:41,790 INFO [PortalImpl:4873]当前URL/jooky生成异常:null

INFO: 14:07:41,790 INFO [PortalImpl:4873] Current URL /jooky generates exception: null

,并重定向到门户网站内的页面,如下所示:

and redirects to a page within the portal that looks like this:

任何人都可以帮助我将这些非文件类型的URL重定向到我的404页面吗?

Can anyone help me redirect these non-file type URL's to my 404 page as well?

谢谢.

推荐答案

在阅读 中未提及的另一项关键问题是portal-ext.properties文件中需要添加的内容. 我必须添加以下内容:

I was still struggling to figure out how to do this until I read the section in the Liferay Developer's Guide about "Overriding a JSP". That told me exactly what I needed to know. Where the 404.jsp file should be stored in my hook, why there was a .portal.jsp file appearing in my liferay installation, etc. One other critical thing that was not mentioned was the addition required to the portal-ext.properties file. I had to add the following:

# 404 page
layout.show.http.status=true
layout.friendly.url.page.not.found=/errors/404.jsp

服务器重新启动后,针对所有不正确的页面开始显示404页面.

After a server restart, the 404 page started displaying for all incorrect pages.

这篇关于当找不到资源时,如何使Liferay 6.1.0始终重定向到404页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆