Question

When deploy a lift app to a tomcat container, it will automatically pretend the context path to all the <a>s whose href are starting with "/". (How is lift doing this?)

But in my Boot.scala, I want to show a custom 500 page, that I use S.render to render a template, and found the links are not handled.

My code:

LiftRules.exceptionHandler.prepend {
  case (runMode, req, exception) =>
    logger.error("Failed at: " + req.uri, exception)
    val content = S.render(<lift:embed what="500"/>, req.request)
    XmlResponse(content.head, 500, "text/html", req.cookies)
}

You can see the line S.render(<lift:embed what="500"/>, req.request)

It will render the webapp/500.html, but without prepending the context path. When I deploy it to tomcat, the page can't show correctly since the js/css files can't load.

How to fix it?

Was it helpful?

Solution

I found the solution:

val content = req.fixHtml(S.render(<lift:embed what="500"/>, req.request))

Notice the req.fixHtml(), it will prepend context path to the links if possible.

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