Reputation: 41
I am new to Grails/Groovy. Please bear with me if this is a silly question.
I am trying to map an URL having querystring parameters in urlmapping.groovy
, something like,
"/rest/employees?empno=123&dept=delivery"(controller:"employees", action="emp")
The values 123
and delivery
are dynamic values. In other words, this could be anything that the user can use.
Apparently this syntax is not correct. What is the right way to achieve this?
Upvotes: 4
Views: 14233
Reputation: 3124
@splix answer is correct. If you want to use a restfull url, you could do something like
"/rest/employees/$empno/$dept"
instead. Otherwise just leave out the part after "?" as said. In your controller you will still get params.empno
and params.dept
Upvotes: 3
Reputation: 35961
Just leave /rest/employees"(controller:"employees", action="emp")
and you'll get your query parameters as params.empno
and params.dept
in your action
Upvotes: 8