1
我創建了一個靜態的URL在Grails
在一個Grails控制器PARAMS:使用URL的某些部分作爲
class UrlMappings {
static mappings = {
...
"/remittance/bank"{
controller={"BankRemittance"}
action=[GET:"index"]
}
"/remittance/bank/$bankId/spd/$spdId"{
controller={"SPD"}
action=[GET:"show"]
}
...
}
}
現在,我要的是在我的SPDController
檢索URL的bankId
和spdId
值:
class SPDController {
def myService
def show() {
String bankId = ? // code to get bankId from the URL
String spdId = ? // code to get spdId from the URL
render(
view: "...",
model: myService.transact(bankId, spdId)
)
}
}
但我該怎麼做?看來使用params.bankId
和params.spdId
不適用於這種情況。
那麼,我的'URLMappings'應該怎麼樣?這只是嗎? – Gideon
正確!在URL中指定變量並定義參數將導致該方法被映射到其等效參數的URL參數調用。 – christopher