javaurl-rewritingocpsoft-rewrite

With ocpsoft rewrite in java remove .xhtml extension


I have this rewriteconfiguration:

return ConfigurationBuilder.begin()
    .addRule(Join.path("/admin/users").to("/admin/users.xhtml"))
    .addRule(Join.path("/admin/test").to("/admin/test.xhtml"))
    .addRule(Join.path("/admin/foo").to("/admin/foo.xhtml"))
    .addRule(Join.path("/admin/bar").to("/admin/bar.xhtml"))
    .addRule(Join.path("/secure/foo").to("/secure/foo.xhtml"))
    .addRule(Join.path("/secure/bar").to("/secure/bar.xhtml"))
    ;

Is there a way that I can map this one time? I just want the .xhtml part is mapped.

I thought something like this would work, but it didden't:

.addRule(Join.path("/admin/*").to("/admin/*.xhtml"))

Solution

  • After more research and googling, i've found the solution:

    return ConfigurationBuilder.begin()
        .addRule(Join.path("/secure/{page}").to("/secure/{page}.xhtml"))
        .addRule(Join.path("/admin/{page}").to("/admin/{page}.xhtml"))
        ;