在HelloWorld.scala中,增加声明
import net.liftweb.http.S
代码修改为:
def foo: NodeSeq = {
val x = S.attr("myparam") openOr "myparam: Y U NO DEFINED!?"
<p>I got {x}!</p>
}
def render = "*" #> <strong>c</strong>
index.html页面修改为
<lift:HelloWorld.foo myparam="3"/> <p></p>
or
<div class="lift:HelloWorld.foo?myparam=4"/>
刷新页面,即可看到捕获的参数
捕获多参数
serve {
case "api" :: "x1" :: _ Get _ =>
for {
r <- S.request if r.get_?
name <- S.param("name")
age <- S.param("age")
} yield <x><name>{name}</name><r>{age}</r></x>
}