使用参数提交表单后,解除重定向到新页面
如何将表单提交的结果传递到我重定向到的页面?
例如,假设我有以下逻辑:
Search Page -> validate
if errors - show Search Page again with errors <--- this part works
else - redirect to New Page(passing search params) <-- no params passed
我的表单处理看起来像这样:
def process() = {
if (nameame== "Joe") {
S.error("Joe not allowed!")
}
val dateRegex="(\\d\\d/\\d\\d/\\d\\d\\d\\d|\\w*)";
if (!birthdate.matches(dateRegex)) {
S.error("birthdate", "Invalid date. Please enter date in the form dd/mm/yyyy.")
}
S.errors match {
case Nil =>S.notice("Name: " + name); S.redirectTo("search-results")
case _ =>S.redirectTo(S.uri)
}
}
如您所见 - 我的搜索结果没有获取“姓名”或“出生日期”参数。当我进行 S.redirectTo 调用时,如何从表单传递参数?
如果我能以某种方式澄清这个问题,请告诉我。
How can I pass results of a form submission to a page that I redirect to?
For example, lets say i have the following logic:
Search Page -> validate
if errors - show Search Page again with errors <--- this part works
else - redirect to New Page(passing search params) <-- no params passed
My form processing looks something like this:
def process() = {
if (nameame== "Joe") {
S.error("Joe not allowed!")
}
val dateRegex="(\\d\\d/\\d\\d/\\d\\d\\d\\d|\\w*)";
if (!birthdate.matches(dateRegex)) {
S.error("birthdate", "Invalid date. Please enter date in the form dd/mm/yyyy.")
}
S.errors match {
case Nil =>S.notice("Name: " + name); S.redirectTo("search-results")
case _ =>S.redirectTo(S.uri)
}
}
As you can see - my search results is not getting a "name" or "birthdate" params. How can I pass the parameters from the form when I do a S.redirectTo call?
Let me know if I can clarify the question somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将参数存储在 SessionVar 中,并从 search_results 片段或任何需要的地方访问它们。请参阅http://stable.simply.liftweb.net/#toc-Section-4.4< /a>.
否则你总是可以这样做:
You can store the parameters in SessionVar's and access them from your search_results snippet or wherever you need them. See http://stable.simply.liftweb.net/#toc-Section-4.4.
Otherwise you could always do: