I´m trying to use ExtensionlessURLs in my JSF app...
I´m using already: https://showcase.omnifaces.org/facesviews/ExtensionlessURLs This works fine, but if I have a URL with a parameter it´s still with:
mypage.jsf?myparameter=12345
Is there a possibility to exclude here also .jsf, so the URL will be:
mypage?myparameter=12345
I know also Prettyfaces is available, but here I guess I have to define for each JSF page a mapping? Therefore I was using Omnifaces...
Any idea to help here?
It appears that you've an existing JSF application whose FacesServlet
is mapped to *.jsf
instead of *.xhtml
and are trying to enable extensionless URLs through OmniFaces FacesViews using its default "minimal" configuration.
This will indeed not work without making other changes to the existing JSF application.
FacesViews expects that you have already mapped the FacesServlet
to the URL pattern of *.xhtml
which is recommended since JSF 2.0. So you need to make the following adjustments:
FacesServlet
mapping from *.jsf
to *.xhtml
in web.xml
..jsf
throughout source code with .xhtml
. So e.g.
ec.redirect(ec.getRequestContextPath() + "/portal/employeeEdit.jsf" + "?id=" + id);
must become
ec.redirect(ec.getRequestContextPath() + "/portal/employeeEdit.xhtml" + "?id=" + id);
A bit decent IDE can do this in a few clicks (e.g. Eclipse Ctrl+H, File Search, find .jsf
in Enclosing project and replace by .xhtml
).Alternatively, wait for OmniFaces 2.7.11 or 3.11 or 4.0-M8 to be released. I've today fixed this backwards compatibility issue in these versions as per issue 623. With this fix, the existing *.jsf
URLs will properly be automatically 301-redirected to the extensionless ones.
Note that this problem is not specifically related to URLs with parameters. It would also happen to URLs without parameters.