Wicket generated URLs is suck and get too long always. The default URL bookmarkable pages contains the fully qualified class name of the page. It look something like following

http://localhost:8080/mkyong?wicket:bookmarkablePage=:com.mkyong.page.ResultPage&url=google.com

What the heck is wicket:bookmarkablePage in URL? I have no idea why Wicket generate such an ugly URL structure. After i deployed Wicket application to client site, many emails sending in from my client question about Wicket bookmarkablePage URL structure. It’s just sound wired and doesn’t make sense at all. What is the advantages of this? Are you going to ask my visitor to bookmark this ugly URL address?…. (I have no idea how do reply it TT).

Lucky , Wicket provides “URL mounting” feature to cloak our ugly URL bookmarkable pages to a specific path in our application.

The URL mounting is typically done in the Wicket “init” method of the application object, as follows

public class MkyongApplication extends WebApplication {
 
	@Override
	protected void init() {
		mount(new QueryStringUrlCodingStrategy("result",ResultPage.class));
	}
}

We can used the mount and QueryStringUrlCodingStrategy URL encoding features to make our Wicket URL structure neat and user friendly. The most important is no more ugly bookmarkable URL :)

The result is like following

http://localhost:8080/mkyong/result?url=google.com
This article was posted in Wicket category.