JSF 2.0 does not have support for extensionless URL by default. This is a long waited feature for the community, but finally we got this with JSF 2.3 (released early 2017). If you care able to update your application to JSF 2.3, or maybe want some more information, please check it out here.
A brief example of how you can make the default JSF approach for extensionless URLs:
In the web.xml file, include each desired mapping using a tag inside the tag:
<url-pattern>/page1</url-pattern>
<url-pattern>/page2</url-pattern>
<url-pattern>/path/page1</url-pattern>
These patterns will redirect the user to the following paths respectively:
- www.domain.com/page1 -> www.domain.com/page1.xhtml
- www.domain.com/page2 -> www.domain.com/page2.xhtml
- www.domain.com/path/page1 -> www.domain.com/path/page1.xhtml
Note that the above examples are not providing a way to redirect to the index.xhtml page, they are just a example of how the new JSF 2.3 mapping work.
However, if you can't update your project right now, I suggest you to follow @Kukeltje advice and take a look on the PrettyFaces library.
PrettyFaces is focused on provide a simple way to create URL mappings for older JSF versions. Heres a example of how it works:
In the pretty-config.xml file, include your desired mappings using a tag:
<url-mapping id="view-page">
<pattern value="/page" />
<view-id value="/page/index.xhtml" />
</url-mapping>
<url-mapping id="view-page-edit">
<pattern value="/page/#{id}" />
<view-id value="/page/edit.xhtml" />
</url-mapping>
These patterns would work like the following examples:
- www.domain.com/page -> www.domain.com/page/index.xhtml
- www.domain.com/page/2 -> www.domain.com/page/edit.xhtml?id=2
Both are good alternatives, PrettyFaces looks more powerful right now, since they are support this kind of solution for more time, but the JSF 2.3 should also do the trick.