S.redirectTo leads always to a blank screen
I am now playing a little bit with lift (2.1), and all the features in LiftRules work as intended. But I haven't been able to use S.redirectTo at all. I always ends with a blank screen, no matter what. No error messages at all!
As an example, I have the following form:
...
<lift:logIn.logInForm form="post">
<p><login:name /></p>
<p><login:password /></p>
<p><login:submit /></p>
</lift:logIn.logInForm>
...
And the code is:
object LogIn extends helper.LogHelper {
...
def logInForm(in: NodeSeq): NodeSeq = {
var name = ""
var password = ""
def login() = {
logger.info("name: " + name)
logger.info("pa开发者_运维知识库ssword: " + password)
if (name == "test1") S.redirectTo("/example")
if (name == "test2") S.redirectTo("/example.html")
if (name == "test3") S.redirectTo("example.html")
S.redirectTo("/")
}
bind("login", in,
"name" -> SHtml.text(name, name = _),
"password" -> SHtml.password(password, password = _),
"submit" -> SHtml.submit("Login", login))
}
}
The method 'login' is invoked, I can check that in the log information. But as I said, no matter which name I enter, I always end with a blank screen, although 'example.html' is available when being accessed directly in the browser. How should I invoke S.redirectoTo in order to navigate to 'examples.html'? Also, why don't I receive an error message (I am logging at a debug level)?
I think all the configuration in Boot is correct, since all LitRules examples (statelessRewrite, dispatch, viewDispatch, snippets) work fine.
Edited:
/example was not in the SiteMap. I have added /example and /index like that:
def boot {
...
val index = Menu(Loc("index", new Link(List("index"), false), "index"))
val example = Menu(Loc("example", new Link(List("example"), false), "example"))
LiftRules.setSiteMap(SiteMap(index, example))
...
}
Still nothing happens :-(
Any idea?
Anything you redirectTo
needs to be in SiteMap.
精彩评论