我正在编写一个Grails应用程序,我希望设置一个允许用户输入图像ID号的表单,并将此值传递给从S3中检索图像的控制器/操作对于给定的图像ID。Grails表单和URL映射
所需的url格式为example.com/results/1234。我已经安装了下列URL映射:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/results/$id?" {
controller = "s3Image"
action = "getS3Image"
}
"/"(view:"/index")
"500"(view:'/error')
}
}
以下是我怎么也安装形式:
<g:form controller="results" method="get">
<input type="text" name="id" class="input-xxlarge" placeholder="http://www.example.com">
<button class="btn btn-inverse">Submit</button>
</g:form>
然而,这似乎形式提交给example.com/results?id=12345。
我该如何改变我的表单或映射,以便在表单提交后生成所需的url?
谢谢!
对不起,迟到的回应,但谢谢!这正是我想要完成的。 –