1

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"?

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
acpuma
  • 479
  • 5
  • 15
  • Could you please post the XHTML page you are attempting to render? Thanks. Additionally, if you could post a sample application on the OCPsoft support forums, it would be very helpful to determing what is going on. http://ocpsoft.org/support/ – Lincoln Jan 18 '14 at 22:18
  • The problem is not about the XHTML page. It is about URL configuration for rewrite. I want to render /admin/admin.xhtml with /admin/ URL. – acpuma Jan 19 '14 at 16:21
  • Yes, I understand this, but the way in which the URL is being rendered is an important factor here. I need to know how the failing link is being generated. – Lincoln Jan 19 '14 at 23:54
  • It happens when i directly enter the URL in the address bar. There is no special command in the XHTML file.I think it happens just when filter matches /admin address. @Lincoln – acpuma Jan 20 '14 at 09:37
  • Okay sorry, I understand. I should learn to read :) I will look in to this and get back to you shortly. – Lincoln Jan 20 '14 at 17:00
  • 1
    Confirmed. This is a bug: https://github.com/ocpsoft/rewrite/issues/160 We will work on fixing ASAP. – Lincoln Jan 21 '14 at 00:37

1 Answers1

1

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>
Lincoln
  • 3,151
  • 17
  • 22