问题
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:
Going to http://localhost:8080/jooky.jsp throws
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
in my Glassfish server log and redirects me to my custom /errors/404.jsp without a problem.
However, going to http://localhost:8080/jooky throws a different error
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:
Can anyone help me redirect these non-file type URL's to my 404 page as well?
Thanks.
回答1:
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
After a server restart, the 404 page started displaying for all incorrect pages.
来源:https://stackoverflow.com/questions/9704706/how-do-i-make-liferay-6-1-0-always-redirect-to-a-404-page-when-a-resource-isnt