How to add a new page in Lift framework

2019-05-11 04:21发布

问题:

How can I add a new page in the webapp directory in lift that can be accessed by users?

Currently only the index.html can be accessed through http://localhost:8080/ or http://localhost:8080/index.html

Say I add a static file newpage.html into webapp dir, then what can I do so users can access it through http://localhost:8080/newpage.html ?

回答1:

It's been a long time since I've done anything with Lift, but from what I remember, the easiest way may be to add the page in the menu entries in the bootstrap.liftweb.Boot.scala class. If you've setup your project using one of Lift's maven archetypes, this class should be there in your project. In this class, there's the following line (or something resembling it, the example I got still uses Lift 1.0, currently I believe they are already heading towards a 2.0 release):


// Build SiteMap
val entries = Menu(Loc("Home", List("index"), "Home")) :: Nil

If you change that line to the following:


val entries = Menu(Loc("Home", List("index"), "Home")) :: Menu(Loc("Welcome", List("welcome"), "Welcome")) :: Nil

than you can acess your welcome page directly.