Web frame request string generator

How do you create a link with query string parameters:

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

in the elevator? I know you can just write it, I'm looking for a wise approach that encodes spaces and other special characters. For instance:

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

Thanks in advance, Etam.

+4
source share
1 answer

There is an appendParams method in appendParams :

 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 the URL as a String, Seq from param-tuples and finally returns String.

+3
source

Source: https://habr.com/ru/post/1336324/


All Articles