php – Symfony2“参数”“用于路由”“必须匹配”[^ /]“(”“给定)以生成相应的URL.”

我有这个路线文件

indexRechercheZones:
    path:     /gestionzonestechniques
    defaults: { _controller: myspaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique }
    requirements:
    methods: GET

modifierZones:
    path:     /gestionzonestechniques/modifier/{nom}
    defaults: { _controller: myspaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:modifierZonesTechnique }
    requirements:
    methods: GET

modifierZones_process:
    path:     /gestionzonestechniques/modifier/process/{nom}
    defaults: { _controller: myspaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:modifierZonesTechnique }
    requirements:
    methods: POST

现在,当我想继续使用indexRechercheZones路由时,发生错误

An exception has been thrown during the rendering of a template
(“Parameter “nom” for route “modifierZones” must match “[^/]++” (“”
given) to generate a corresponding URL.”) in
myspaceGestion…sBundle:…:indexZonesTechniques.html.twig
at line 71.

在我的树枝线71中,我有这个代码

<a href="{{ path('modifierZones', {'nom': zonetechnique.nom}) }}"><button class="btn btn-warning btn-xs">Modifier</button></a>

我认为这是一个正则表达式问题,symfony的url编写规则存在问题,但我不知道如何修复此错误.我尝试过在我的路线中添加这一行的一些事情:

indexRechercheZones:
    path:     /gestionzonestechniques/
    defaults: { _controller: myspaceGestionEquipementsTechniquesBundle:GestionZonesTechniques:indexZonesTechnique }
    requirements:
        nom:    \d+ 
    methods: GET

或者像这样要求:

requirements:
    nom:    '[a-zA-Z0-9-_\/-\s.^]+'

但它不匹配.有人可以帮忙吗?

谢谢…

解决方法:

就像@Coussinsky所说,你的字段“nom”的某些值在你的数据库中是空的.

如果需要,可以将此参数设置为null,或者只更改数据库中的空值.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...