index的對應的是哪個controller和action呢

2 views
Skip to first unread message

derekypp peng

unread,
Jan 15, 2010, 2:17:37 AM1/15/10
to grail...@googlegroups.com
Hi,all

一般來說http://myProject/User/List

對於的controller 是UserControoler 裡面的List 這個action


可是如果是進去就看到的index的對應的是哪個controller和action呢
http://myProject/index

因為也必須在這裡寫不少的code 不想在index寫太多<%..........%>
覺得自已都快看不懂了


請問一下大家,thanks~





Ford Guo

unread,
Jan 15, 2010, 2:30:34 AM1/15/10
to grail...@googlegroups.com
你可以在URLMaping的配置中,自己去定义映射到那个Controller
Ford Guo


2010/1/15 derekypp peng <dere...@gmail.com>
--
您收到此邮件是因为您订阅了 Google 网上论坛的“Grails联盟-GrailsUnion”论坛。
要向此网上论坛发帖,请发送电子邮件至 grail...@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 grailsunion...@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/grailsunion?hl=zh-CN 访问此网上论坛。


Alex wang

unread,
Jan 15, 2010, 2:34:36 AM1/15/10
to grail...@googlegroups.com
大致明白你的意思,但是觉得你的表述比较含糊

http://myProject/index  这种模式一般没人用吧? 要么就是http://myProject/   这样访问比较符合逻辑,这里一般你可以用url mapping里配置指向一个你需要的controler以及action,当然,你也可以不要指向controller,直接用webapp里的index.html就可以
---------------------------------------------
Alex wang
website:颠覆软件 http://www.foxlog.org
twitter: http://twitter.com/foxlog
douban: http://www.douban.com/people/foxlog
gmail: idea.wang[at]gmail.com


2010/1/15 Ford Guo <agil...@gmail.com>

derekypp peng

unread,
Jan 15, 2010, 3:10:12 AM1/15/10
to grail...@googlegroups.com
謝謝大家的回復

url mapping{
   "/"(controller:'home',action:'index')
}

再建立一個homeController就可以囉~
謝謝大家~


2010/1/15 Alex wang <idea...@gmail.com>

zongzi

unread,
Jan 15, 2010, 7:48:54 PM1/15/10
to grail...@googlegroups.com
弱弱的问一下,这句是放在哪个文件里面的啊?

2010/1/15 derekypp peng <dere...@gmail.com>



--
行为源自需求,理念成就未来!

derekypp peng

unread,
Jan 15, 2010, 8:02:36 PM1/15/10
to grail...@googlegroups.com
放在 你的專案下\grails-app\conf\UrlMappings.groovy 裡就可以用了喔



2010/1/16 zongzi <hongh...@gmail.com>
1E3.gif
Reply all
Reply to author
Forward
0 new messages