Lift Web Framework query string generator
How do you create a link with query string parameters:
/path/to/view?param=358&name=Something+with+space开发者_开发百科s
in Lift? I know you can simply write it, I am looking for a wise approach, which encode spaces and other special characters. For example:
Link("path/to/view").param("param", 358).param("name", "Something with spaces")
Thanks in advance, Etam.
There is appendParams
method in net.liftweb.util.HttpHelpers
trait:
import net.liftweb._
import util.Helpers._
val url = appendParams("/path/to/view",
("param" -> "358") ::
("name" -> "Something with spaces") :: Nil)
Reply from Scala REPL:
url: String = /path/to/view?param=358&name=Something+with+spaces
As you can see, it gets URL as a String, Seq
of param tuples and finally returns String.
精彩评论