routes - Zend Framework 3 Route Segment 参数问题
问题描述
在我的 module.config.php 中,我有一个如下所示的路由配置。在“ hizmetgetir ”路线,我有名为“ search ”的参数,以及它的约束。但我有这样的错误:“请求的 URL 无法通过路由匹配。”。
当我用“ id ”更改约束“ search ”时,我没有问题,我可以在控制器中捕获路由搜索参数。在我看来,参数名称和约束名称必须相同。问题是什么。谢谢。
老的
'hizmetgetir' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/hizmetgetir[/:search]',
'constraints' => [
**'search' => '/[0-9a-zA-Z\s\'.;-]+/',**
],
'defaults' => [
'controller' => Controller\ProfilController::class,
'action' => 'ajaxhizmetgetir',
],
],
]
新的
'hizmetgetir' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/hizmetgetir[/:search]',
'constraints' => [
'id' => '/[0-9a-zA-Z\s\'.;-]+/',
],
'defaults' => [
'controller' => Controller\ProfilController::class,
'action' => 'ajaxhizmetgetir',
],
],
],
我的全路线会议。
'router' => [
'routes' => [
'rehberim' => [
'type' => 'Literal',
'options' => [
// Change this to something specific to your module
'route' => '/rehberim',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
'profil' => [
'type' => \Zend\Router\Http\Literal::class,
'options' => [
'route' => '/profil',
'defaults' => [
'controller' => Controller\ProfilController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'hizmetgetir' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/hizmetgetir[/:search]',
'constraints' => [
'id' => '/[0-9a-zA-Z\s\'.;-]+/',
],
'defaults' => [
'controller' => Controller\ProfilController::class,
'action' => 'ajaxhizmetgetir',
],
],
],
'profiluzman' => [
'type' => Segment::class,
'options' => [
'route' => '/profiluzman[/:id]',
'defaults' => [
'action' => 'profiluzman',
],
'constraints' => [
'id' => '[0-9]+',
],
],
],
'profiluser' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/profiluser[/:id]',
'defaults' => [
'action' => 'profiluser',
],
'constraints' => [
'id' => '[0-9]+',
],
],
],
'profiladay' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/profiladay[/:id]',
'constraints' => [
'id' => '[0-9]+',
],
'defaults' => [
'action' => 'profiladay',
],
],
],
'profilolustur' => [
'type' => \Zend\Router\Http\Segment::class,
'options' => [
'route' => '/profilolustur',
'defaults' => [
'action' => 'profilolustur',
],
],
],
],
],
],
]
解决方案
推荐阅读
- r - 如何处理 R 中合并的列标题?
- apache-kafka - 如何为 Confluent Schema Registry 指定 nodePort?
- autodesk-data-management - Data Management API 获取文档的完整文件夹路径
- r - 在 Shiny 中选择单选按钮的活动选项卡
- flutter - RenderBox 未布置:RenderFittedBox#79644 relayoutBoundary=up1
- nlp - XLNetForSequenceClassification 预训练模型无法加载
- google-colaboratory - 从 Google Colabortory 下载输出文件
- php - axios 请求返回错误 500 (laravel, axios & vuejs)
- python - 为什么这个方法说 1 的平方是 3?
- c - 为什么未签名被视为已签名?