我的grails控制器由以下URL调用
/center/madrid/12-de-octubre
/center/madrid/12-de-octubre?opt=1
如果后面有任何参数,我需要控制器的行为不同吗?在网址
我有以下网址映射:
name center: "/center/$_uni_city/$_uni_facility_name" {
controller = "site"
action = "centerprofile"
}
虽然我可以找到所有参数(例如_uni_city = Madrid,opt = 1),但在应用URLMappings后,我无法确定哪些参数来自查询字符串(即在上面的示例中选择)。
有没有办法检索原始请求网址(即 / center / madrid / 12-de-octubre?opt = 1)在grails控制器中?
答案 0 :(得分:4)
要获取请求网址中的原始参数,请使用:
request.queryString
答案 1 :(得分:4)
请参阅Grails request的说明。
解决方案:
class URLController{
def printCurrentUrl = {
render request.forwardURI
}
}