在启动时使用index.html之外的页面提取简单的SiteMap

时间:2012-10-23 11:15:24

标签: scala lift

这是我目前坚持的另一个与Scala / Lift相关的问题。

我在http://simply.liftweb.net/index-Chapter-2.html#toc-Chapter-2跟随无处不在的聊天应用示例,一切都已启动并运行。现在,我只想在index.html Boot.scala中嵌入另一个HTML页面而不是SiteMap,我看到的是以下消息:

  

在此服务器上找不到请求的网址

所以,为了向您展示我的努力,我会在SiteMap中向您展示Boot.scala定义:

// Build SiteMap
def sitemap() = SiteMap(
  Menu("Home") / "index" :: // Simple menu form
  // Menu with special Link
  Menu(Loc("Static", Link(List("static"), true, "/static/index"), 
       "Static Content")) ::
  // Menu entries for the User management stuff
  User.sitemap :_*)

LiftRules.setSiteMapFunc(sitemap)

index.html位于webapp文件夹下,因此其路径如webapp/index.html。以下是index.html的内容:

<div id="main" class="lift:surround?with=default;at=content">
<!-- the behavior of the div -->
<div class="lift:comet?type=Chat">
    Some chat messages
    <ul>
        <li>A message</li>
        <li class="clearable">Another message</li>
        <li class="clearable">A third message</li>
    </ul>
</div>

<div>
    <form class="lift:form.ajax">
        <input class="lift:ChatIn" id="chat_in"/>
        <input type="submit" value="Say Something"/>
    </form>
</div>

所有这些都是在聊天应用示例中制作的。现在我只想显示一个简单的login.html文件,而不是index.html,因此我将其放在webapp/login.html下。此文件的内容如下:

<div id="loginContainer" class="lift:surround?with=default;at=content">
<!-- the behavior of the div -->
<div>
    <form class="lift:form.ajax">
        <div class="loginInputWrapper">
            <input type="text" class="txtLogin lift:LogIn" id="loginName"/>
        </div>
        <div class="loginInputWrapper">
            <input type="password" class="pwLogin lift:LogIn" />
        </div>
        <div class="buttonWrapper loginButtonWrapper">
            <button id="loginButton" class="hiddenButton qsbfont" type="submit">Login</button>
        </div>
    </form>
</div>

我改编了这样的SiteMap定义:

Menu("Home") / "login" :: // Simple menu form

在我看来,好像它应该像启动时包含index.html那样顺利运行,但如果我想访问该网站,我会一遍又一遍地看到所提到的消息。 有没有人知道这里发生了什么,可以给我一个提示/解决方案吗?

如果感兴趣:我在Intellij IDEA Enterprise中运行Tomcat 7上的Scala WAR(试用许可证)

1 个答案:

答案 0 :(得分:0)

index.html是请求/时显示的默认页面。你为什么要改变它?将login.html重命名为index.html或使用网址重写。但是,最后一个选项只会让任何想要阅读源代码的人感到困惑。

错误消息的原因是您请求/并且(我假设)SiteMap中没有“index”条目,因此它不知道如何处理请求。它无法知道您希望login.html成为默认页面。