2016-11-17 75 views
0

我需要为“toolsearch”页,“搜索”页面中的所有请求重定向所有的参数斯卡拉/电梯 - 如何使用params做页面重定向?

所以localhost:8080/toolsearch#?q=20需要被重定向到localhost:8080/search#?q=20

我试图使用Boot添加liftrules为重定向

LiftRules.statelessRewrite.prepend { 
     case RewriteRequest(ParsePath("toolsearch" :: Nil, "", x, y), z, s) => {   
     RewriteResponse("search" :: "index" :: Nil, Map("page" -> "search")) //Works but the browser address bar says 'toolsearch' not 'search 
//  S.redirectTo("/search") //throws net.liftweb.http.ResponseShortcutException: Shortcut 
//  JsCmds.RedirectTo("/search") //doesnt compile 
     } 
    } 

任何与此有关的帮助表示赞赏。谢谢。

回答

0

花一些时间来尝试不同的事情之后,这是我发现,工作解决方案:

LiftRules.dispatch.prepend { 
    case Req("toolsearch" :: Nil, _, _) =>{ 
    () => Full(RedirectResponse("/search")) 
    } 
} 

ref

请让我知道,如果你有一个更好的解决方案。