这是我目前坚持的另一个与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(试用许可证)
答案 0 :(得分:0)
index.html
是请求/
时显示的默认页面。你为什么要改变它?将login.html
重命名为index.html
或使用网址重写。但是,最后一个选项只会让任何想要阅读源代码的人感到困惑。
错误消息的原因是您请求/
并且(我假设)SiteMap
中没有“index”条目,因此它不知道如何处理请求。它无法知道您希望login.html
成为默认页面。