views:

191

answers:

1

Hi I'm having some trouble with Lift and URL rewriting. I've written a simple rewrite rule:

LiftRules.rewrite.append {
  case RewriteRequest(
    ParsePath(List("user", userID), _, _, _), _, _) => {
        println(userID)
        RewriteResponse(List("viewUser"), Map("userID" -> urlDecode(userID)))
    }
}

So when I enter http://localhost:8080/user/brian I expect a call to be made to the viewUser.html file I have placed in the webroot directory. The mark up of viewUser.html is very simple:

<lift:surround with="default" at="content">
    <p>ViewUser</p>
</lift:surround>

But instead of seeing viewUser I get an error:

The Requested URL /user/brian was not found on this server

Also if I enter the URL of viewUser by hand: http://localhost:8080/user/brian I get the same error.

I am out of ideas on this one, I did find a similar error which happens through the SiteMap system.

I've tried this with a cleanly checked out lift-archetype-blank project, by adding the viewUser.html and adding the single chunk of rewrite code.

+2  A: 

Make sure you've added "viewUser" to the site map. Without doing so Lift doesn't know where to find page.

Xavi
Excellent, works fine now. I'm working through the Exploring Lift book at the moment, I didn't see this explicitly mentioned in the Lift Fundamentals chapter? Ah well one way or another it works now ;)
Brian Heylin