UrlMapping Question ...

瀏覽次數:6 次
跳到第一則未讀訊息

Saleh Mamdouh

未讀,
2016年6月21日 凌晨3:16:402016/6/21
收件者: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

未讀,
2016年6月21日 上午8:07:232016/6/21
收件者: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/
回覆所有人
回覆作者
轉寄
0 則新訊息