Gideon
Gideon

Reputation: 1594

Using certain parts of URL as params in a Grails Controller

I've created a static URL in Grails:

class UrlMappings {
    static mappings = {
        ...

        "/remittance/bank"{
            controller={"BankRemittance"}
            action=[GET:"index"]
        }
        "/remittance/bank/$bankId/spd/$spdId"{
            controller={"SPD"}
            action=[GET:"show"]
        }

        ...
    }
}

Now what I want is to retrieve bankId and spdId values of the URL on my SPDController:

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)
        )
    }
}

But how can I do that? It seems using params.bankId and params.spdId is not for this scenario.

Upvotes: 1

Views: 35

Answers (1)

christopher
christopher

Reputation: 27356

Your action should accept the URL parameters as arguments.

def show(String bankId...)

Upvotes: 3

Related Questions