Question

I want to rewrite my urls like this:

/admin/ -> /admin/admin.xhtml

I wrote this code:

return ConfigurationBuilder.begin()
        .addRule(TrailingSlash.append())
                .when(Path.matches("/{page}"))
                .perform(Forward.to("/{page}/{page}.xhtml"))

but with this configuration I got this exception:

org.ocpsoft.rewrite.exception.ParameterizationException:
Must supply [2] values to build output string.

How can i use one variable from "when", twice in "perform"?

Was it helpful?

Solution

This bug has been documented in the Rewrite issue tracker, has now been resolved, and will be included in the 2.0.11.Final release of Rewrite in the next few days. Until then you can use the latest 2.0.11-SNAPSHOT when it deploys to the Sonatype Snapshots repository tonight, or build from sources if you need it sooner (https://github.com/ocpsoft/rewrite):

<dependency>
   <groupId>org.ocpsoft.rewrite</groupId>
   <artifactId>rewrite-servlet</artifactId>
   <version>2.0.11-SNAPSHOT</version>
</dependency>

<!-- To use snapshots, you must also use the Sonatype Snapshots respository -->
<repository>
   <id>sonatype-snapshots</id>
   <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top