Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top