How to add a new page in Lift framework

佐手、 提交于 2019-12-07 16:48:15

问题


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.



来源:https://stackoverflow.com/questions/2886921/how-to-add-a-new-page-in-lift-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!