Я бы рекомендовал использовать для этого Rewrite (https://www.ocpsoft.org/rewrite). Он уже включен в ваш проект с PrettyFaces:
package com.example;
@RewriteConfiguration
public class ExampleConfigurationProvider extends HttpConfigurationProvider
{
@Override
public int priority()
{
return 10000000; // Very large priority # should occur last.
}
@Override
public Configuration getConfiguration(final ServletContext context)
{
return ConfigurationBuilder.begin()
.addRule()
.when(
// filter inbound requests only
Direction.isInbound()
// match all paths
.and(Path.matches("/{p}"))
// only catch requests if they were not already internally forwarded by another rule
.and(Not.any(DispatchType.isForward()))
)
// Show the 404 page.
.perform(Forward.to("/404"))
// Allow "p" to match any URL path
.where("p").matches(".*");
}
}