ZF2路径参数带有斜线 [英] ZF2 route parameters with slash

查看:117
本文介绍了ZF2路径参数带有斜线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用包含正斜杠的参数来组装一条路线?

Is it possible to assemble a route with parameters containing forward slashes?

Config:

'someroute' => array(
       'type' => 'Zend\Mvc\Router\Http\Segment',
       'options' => array(
                'route' => 'someroute/:path',
                'defaults' => array(
                    'controller' => 'Controller',
                    'action' => 'index'
                ),
                'constraints' => array(
                    'path' => '(.)+'
                )
       )
 )

控制器:

$path = 'some/subdirectory';
$this->url('someroute', array('path' => $path));

结果:

http://host.name/someroute/some%2Fsubdirectory


推荐答案

在视图中使用 rawurldecode()当然可以解决此问题。

Using rawurldecode() in the view solves this issue of course.

这篇关于ZF2路径参数带有斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆