简体   繁体   English

在渲染模板期间抛出异常(路由“delete_User”的“参数”salt“必须匹配”[^/]++“

[英]An exception has been thrown during the rendering of a template (“Parameter ”salt“ for route ”delete_User“ must match ”[^/]++"

i would to create a methode to delete some user who classified in table this is my methodedelete我会创建一个方法来删除一些在表中分类的用户这是我的方法删除

public function deletetAction(User $user)
{
    if (!$user) {
        throw $this->createNotFoundException('No user found');
    }

    $em = $this->getDoctrine()->getEntityManager();
    $em->remove($user);
    $em->flush();

    return $this->redirectToRoute('index_User');
}

and i call this methode in my views like this index.html.twig我在我的观点中称这个方法为 index.html.twig

<tbody>
                 {% for user in useres %}
                    <tr>

                  <td> {{user.username}}  </td>
                  <td> {{user.email}}  </td>
                  <td> {{user.date(user.LastLogin)}}</td> 
                   <td> {{user.enabled}}  </td>
                   <td class="center hidden-400">        
                       <a href="{{ path('delete_User', {'salt':user.salt }) }}"class="glyphicon glyphicon-pencil">delete </a>

                                    </td>

                  <td>{{user.roles[0]}}</td>
                                </tr>
                {% endfor %}
</tbody>

but when i execute the route index this error is posted但是当我执行路由索引时,会发布此错误

Probably, some values for your field salt are empty in the database.可能,您的字段salt的某些值在数据库中为空。 So, you should make a check before rendering a link.因此,您应该在呈现链接之前进行检查。

{% if user.salt|length %}
    <a href="{{ path('delete_User', {
        'salt': user.salt
    }) }}" class="glyphicon glyphicon-pencil">delete</a>
{% endif %}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在渲染模板期间引发了异常(“无法解析依赖项 [Parameter #0 [ $listing ]]”) - An exception has been thrown during the rendering of a template (“Unable to resolve dependency [Parameter #0 [ $listing ]]”) Twig在Laravel中报告“在渲染模板期间引发了异常” - Twig reports “An exception has been thrown during the rendering of a template” in Laravel symfony在渲染模板时抛出了异常 - symfony An exception has been thrown during the rendering of a template 呈现模板期间引发了异常(“ A __toString()” - An exception has been thrown during the rendering of a template (“A ”__toString()" Symfony 错误:“呈现模板期间抛出异常” - Symfony Error: "An exception has been thrown during the rendering of a template" Symfony-呈现模板期间引发了异常 - Symfony - An exception has been thrown during the rendering of a template 在渲染模板期间抛出异常(“找不到控制器: - An exception has been thrown during the rendering of a template ("Controller not found: 模板渲染过程中抛出异常(“Catchable Fatal Error: Object of class could not be convert to string”) - An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class could not be converted to string") Symfony和Doctrine问题&#39;在渲染模板期间引发了异常(“注意:未定义索引:设备”) - Symfony and Doctrine Issue 'An exception has been thrown during the rendering of a template (“Notice: Undefined index: equipe”) 在呈现模板期间抛出异常(“警告:字符串转换时丢失数据”) - An exception has been thrown during the rendering of a template ("Warning: Loss of data on string conversion")
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM