UrlMapping Question ...

6 views
Skip to first unread message

Saleh Mamdouh

unread,
Jun 21, 2016, 3:16:40 AM6/21/16
to grails-de...@googlegroups.com
Hi,

I tried to look int the UrlMapping documentation and Grails documentation and did not find a complete answer. Maybe I missed something while looking in the documentation, this asking here ...

Question : Can I map a URL to just a controller ?
For example :
"/test" (Controller:"hello").

By that mapping, I would assume that "/test/action1" would be automatically mapped to HelloController::action1 and "/test/action2" would automatically map to HelloController::action2.

Another sub-question:
Can I use parts of the URL to determine the action name.
Ex: "/test/$var1" (Controller:"$var1_old") ?

Thanks

Regards,

Jeff Brown

unread,
Jun 21, 2016, 8:07:23 AM6/21/16
to grails-de...@googlegroups.com
On June 21, 2016 at 2:16:53 AM, Saleh Mamdouh
(salehmam...@gmail.com) wrote:
>
>
> Question : Can I map a URL to just a controller ?
> For example :
> "/test" (Controller:"hello”).

Yes, but you would use “controller” instead of “Controller”.

>
> By that mapping, I would assume that "/test/action1" would be automatically
> mapped to HelloController::action1 and "/test/action2" would automatically
> map to HelloController::action2.

No, the above mapping would map to the default action in
HelloController.  If you want “/test/action1” to map to action1 and
“/test/action2” to map to action2 then you could do something like
this:

“/test/$action”(controller: ‘hello’)


>
> Another sub-question:
> Can I use parts of the URL to determine the action name.
> Ex: "/test/$var1" (Controller:"$var1_old") ?
>

I can’t tell what “$var1_old” is supposed to be there.  The question
as written “Can i use parts of the URL to determine the action name”
is answered in my answer to the previous question.




JSB

--
Jeff Scott Brown
OCI Grails Practice Lead
Principal Software Engineer

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/
Reply all
Reply to author
Forward
0 new messages