2011-01-20 18 views
4

如何創建與查詢字符串參數的鏈接:提升Web框架查詢字符串發電機

/path/to/view?param=358&name=Something+with+spaces 

在電梯?我知道你可以簡單地寫它,我正在尋找一種明智的方法,它編碼空間和其他特殊字符。例如:

Link("path/to/view").param("param", 358).param("name", "Something with spaces") 

在此先感謝, Etam。

回答

3

appendParams方法net.liftweb.util.HttpHelpers特點:

import net.liftweb._ 
import util.Helpers._ 

val url = appendParams("/path/to/view", 
         ("param" -> "358") :: 
         ("name" -> "Something with spaces") :: Nil) 

從斯卡拉REPL回覆:

url: String = /path/to/view?param=358&name=Something+with+spaces 

正如你所看到的,它得到URL作爲一個字符串,PARAM元組最後返回的Seq串。