doormen2014
2014-07-16 08:41
浏览 89
已采纳

Zend framework2 +带参数的路由

I want to write custom routing in Zend framework2. I prepared following code:

'objects' => array(
            'type' => 'Literal',
            'options' => array(
                'route' => '/objects',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller' => 'Index',
                    'action' => 'decode',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type' => 'Segment',
                    'options' => array(
                        'route' => '/[:mask]',
                        'constraints' => array(
                            'mask' => '[a-zA-Z][a-zA-Z0-9_-.,]*',
                        ),
                        'defaults' => array(

                        ),
                    ),
                ),
            ),
        ),

I must routing adres like this:

http://restaurations.en/objects/cracow,0.html

http://restaurations.en/objects/cracow,swam,1.html

http:restaurations.en/objects/swam,3.html

The blod text I must get in my controller. Also, How should I prepre corect router?? How can I do it?

图片转代码服务由CSDN问答提供 功能建议

我想在Zend framework2中编写自定义路由。 我准备了以下代码:</ p>

 'objects'=&gt; 数组(
'类型'=&gt;'文字',
'选项'=&gt;数组(
'路由'=&gt;'/ objects',
'默认'=&gt;数组(
'  __NAMESPACE__'=&gt;'应用程序\控制器',
'控制器'=&gt;'索引',
'动作'=&gt;'解码',
),
),
'may_terminate'=&gt  ; true,
'child_routes'=&gt;数组(
'默认'=&gt;数组(
'类型'=&gt;'细分',
'选项'=&gt;数组(
'路线'  =&gt;'/ [:mask]',
'constraints'=&gt; array(
'mask'=&gt;'[a-zA-Z] [a-zA-Z0-9 _-。,] *  ',
),
'默认'=&gt;数组(
 
),
),
),
),
),
 </ code> </ pre> 
  
 

我必须像这样路由地址:</ p>

http://restaurations.en/objects/ cracow,0.html < / strong> </ p>

http://restaurations.en/objects/ 克拉科夫,游泳,1.html </ strong> </ p>

http:restaurations.en / objects / swam,3.html </ strong> </ p> \ n </ blockquote>

我必须在我的控制器中获得的blod文本。 另外,我应该如何预制corect路由器? 我该怎么办?</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题