【发布时间】:2019-01-29 10:29:08
【问题描述】:
我正在使用 ZF3,在 Post 模块的 module.config.php 文件中,我有这两条路线之一,
'create-post' => [
'type' => Literal::class,
'options' => [
// Change this to something specific to your module
'route' => '/post/create',
'defaults' => [
'controller' => Controller\PostController::class,
'action' => 'create',
]
],
'may_terminate' => true,
'child_routes' => [
// You can place additional routes that match under the
// route defined above here.
],
],
'post' => [
'type' => Segment::class,
'options' => [
// Change this to something specific to your module
'route' => '/post[/:postId]',
'defaults' => [
'controller' => Controller\PostController::class,
'action' => 'show',
],
'constraints' => array(
'postId' => '\d{4}'
)
],
'may_terminate' => true,
'child_routes' => [
// You can place additional routes that match under the
// route defined above here.
],
]
现在当我访问 http://localhost:8080/post/create 时,它可以工作,但是当我访问 http://localhost:8080/post/32 时,它不起作用。它说 404 错误,找不到页面。
非常感谢任何帮助。
【问题讨论】:
-
ID 必须是 4 位数字,不是吗?
-
不,可以是任意4位数字
-
这和我说的有什么不同? localhost:8080/post/32 不是 4 位,是 2,所以不匹配?
-
我的意思是最多 4 位数字
-
现在可以用了,我把它改成了2
标签: php zend-framework routes zend-framework3