Wednesday, 25 March 2009

Tuckey URL Rewriter

I have been using a url rewriting plugin for Spring, that allows urls to be less cluttered with querystring params. I am using it as an interim step before sorting a proper photo cache.

What I want is to have a url like:


Spring 3.0 will allow this kind of thing, but for the moment there is a url rewriting filter from

The steps I used were:

1. Add a dependency to the pom file


2. Add a filter to web.xml


3. Add a file called urlwrite.xml to WEB-INF

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE urlrewrite PUBLIC "-// UrlRewrite 3.0//EN" "">

Where <from> and <to> are regular expression match and replace values

4. Create a normal Spring controller and configuration to handle requests like


This means that later I can cache the picture as a file and change the controller to being a 404 handler.

No comments:

Post a Comment