按照您的思路解决了。灵异的是,那天我的思路也是这样的。谢谢。
在 2010年12月27日 上午9:28,Fayland Lam <[email protected]>写道: > i don't have any issue with the code. > > > any ['get', 'post'] => '/query' => sub { > > my $name = params->{name}; > print STDERR "name: $name\n" if $name; > > template 'query'; > }; > > when on submit. I see debug console as: > > [572] core @0.000120> request: POST /query from 127.0.0.1 in > C:/strawberry/perl/site/lib/Dancer/Handler.pm l. 48 > [572] core @0.000890> [hit #9] trying to match `/query' against > /^\/query$/ in C:/strawberry/perl/site/lib/Dancer/Route.pm l. 74 > [572] core @0.001328> [hit #9] --> got 1 in > C:/strawberry/perl/site/lib/Dancer/Route.pm l. 80 > name: test > [572] core @0.005029> [hit #9] response: 200 in > C:/strawberry/perl/site/lib/Dancer/Handler.pm l. 131 > > Thanks. > > > > On 2010/12/26 22:29, Fayland Lam wrote: > >> Sorry, got to sleep. yeah, I'll test it tomorrow and get back to you >> later. >> >> Thanks >> >> 2010/12/26 九剑独孤<[email protected]>: >> >>> 捕获不到,呵呵。 >>> >>> 在 2010年12月26日 下午10:15,Fayland Lam<[email protected]>写道: >>> >>>> :) >>>> >>>> try >>>> >>>> any ['get', 'post'] => '/query' => sub { >>>> >>>> } >>>> >>>> 2010/12/26 九剑独孤<[email protected]>: >>>> >>>>> 看来,我没有把自己的意思说清楚。其实我是不知道如何构造一个表单,按了提交按钮后,能被Dancer的router捕获。 >>>>> 这是我构造的表单: >>>>> <!DOCTYPE html >>>>> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >>>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >>>>> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" >>>>> xml:lang="en-US"> >>>>> <head> >>>>> <title>表格录入处理</title> >>>>> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> >>>>> </head> >>>>> <body> >>>>> <H1>***查询</H1> >>>>> <form method="post" action="http://192.168.1.101:3000/query" >>>>> enctype="multipart/form-data"> >>>>> 识别号:<input type="text" name="name" /><P>表格类型<P><label><input >>>>> type="radio" >>>>> name="words" value="新办事项" checked="checked" >>>>> />新办事项</label><P><label><input >>>>> type="radio" name="words" value="变更事项" checked="checked" >>>>> />变更事项</label><P><label><input type="radio" name="words" value="新设事项" >>>>> checked="checked" />新设事项</label><P><label><input type="radio" >>>>> name="words" >>>>> value="注销事项" checked="checked" />注销事项</label><P><input type="submit" >>>>> name="submit" value="提交并保存(按回车键直接选中)" /><div><input type="hidden" >>>>> name=".cgifields" value="words" /></div></form> >>>>> </body> >>>>> </html> >>>>> >>>>> 按了提交按钮后,Dancer捕获的始终是get请求,而不是post,我不知道怎么构造它。 >>>>> >>>>> 在 2010年12月26日 下午10:04,Fayland Lam<[email protected]>写道: >>>>> >>>>>> use params, for example: >>>>>> >>>>>> my $form_input_name1 = params->{name1}; >>>>>> >>>>>> 2010/12/26 独孤九剑<[email protected]>: >>>>>> >>>>>>> get '/query' => sub { >>>>>>> #产生一个表单 >>>>>>> } >>>>>>> >>>>>>> >>>>>>> >>>>>>> 如何在Dancer里获得这个表单的数据呢?我需要表单提供的数据,然后相应产生动态内容,比如,把表单提交的内容存入数据库,然后输出是否成功保存的 >>>>>>> 信息。谢谢。 >>>>>>> >>>>>>> On 12月26日, 下午1时17分, Fayland Lam<[email protected]> wrote: >>>>>>> >>>>>>>> something like this may >>>>>>>> >>>>>>>> help: >>>>>>>> http://blogs.perl.org/users/mstplbg/2010/12/using-anyevent-and-dancer...http://blogs.perl.org/users/mstplbg/2010/12/anyevent-and-dancer-condv. >>>>>>>> .. >>>>>>>> >>>>>>>> anyway, I didn't try fork or Coro in Dancer so I can't tell a >>>>>>>> solution. >>>>>>>> but from the comment, the Dancer author Sawyer did fork in Dancer. >>>>>>>> so >>>>>>>> you may want to send an email to dancer mailing >>>>>>>> list:http://lists.perldancer.org/cgi-bin/listinfo/dancer-users >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>>> On 2010/12/26 13:10, JohnTeee wrote: >>>>>>>> >>>>>>>> С ſ ʼ Dancer, win32 StandAlone ʽ >>>>>>>>> Ȼ ڽ fork, Լ CPAN ϵ Coroģ 鶼 >>>>>>>>> Ƿ Ҫ CGI ķ ʽ , ܹ ͬʱ App? >>>>>>>>> Ҫ Ĺ , Ϊ: >>>>>>>>> һ request , ⲿָ ȴ ʱ , >>>>>>>>> ͬʱ ʹ ߵȴ , ô ͻῨס--->ֱ һ request >>>>>>>>> ǰ Ҳ ͬ ? >>>>>>>>> >>>>>>>> -- >>>>>>>> Fayland Lam //http://www.fayland.org/ >>>>>>>> >>>>>>> -- >>>>>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>>>>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>>>>>> 要取消订阅此网上论坛,请发送电子邮件至 >>>>>>> [email protected]<perlchina%[email protected]> >>>>>>> 。 >>>>>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。 >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> -- >>>>>> Fayland Lam // http://www.fayland.org/ >>>>>> >>>>>> -- >>>>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>>>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>>>>> 要取消订阅此网上论坛,请发送电子邮件至 >>>>>> [email protected]<perlchina%[email protected]> >>>>>> 。 >>>>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>>>>> >>>>>> -- >>>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>>>> 要取消订阅此网上论坛,请发送电子邮件至 >>>>> [email protected]<perlchina%[email protected]> >>>>> 。 >>>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>>>> >>>>> >>>> >>>> -- >>>> Fayland Lam // http://www.fayland.org/ >>>> >>>> -- >>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>>> 要取消订阅此网上论坛,请发送电子邮件至 >>>> [email protected]<perlchina%[email protected]> >>>> 。 >>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>>> >>>> -- >>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>> 要取消订阅此网上论坛,请发送电子邮件至 >>> [email protected]<perlchina%[email protected]> >>> 。 >>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>> >>> >> >> > > -- > Fayland Lam // http://www.fayland.org/ > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 > [email protected]<perlchina%[email protected]> > 。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > > -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
