且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

POST错误500:内部服务器错误

更新时间:2022-10-20 16:41:09

我也遇到过与表单处理相同的问题。



解决方案是清除缓存手动并重新预热。 应用程序/控制台缓存:清除==>不会为我工作,所以我这样做:
$ b $ r rm -rf app / cache / dev

php应用程序/控制台缓存:热身

解决了问题!

但问题是什么?
我发现500内部服务器错误被抛出,因为它尝试在app / cache / dev / annotations中加载缓存的路由值(在我的情况中)。

提示:我之前在控制器中使用了注释模板和路由。现在我正在使用外部文件路由...这是我的痛苦...我忘记了清除缓存手动 !!!


I'm trying to build a form with Symfony2 and when I click on my button to submit the form, i get a POST method with a 500 Internal server error.

Here is the code on my controller to validate the form:

if ($request->getMethod() == 'POST')
    {
        $form->bindRequest($request);
        if ($form->isValid())
        {

            $em = $this->getDoctrine()->getEntityManager();             
            $em->persist($group);
            $em->flush();
            return $this->redirect($this->generateUrl('index'));
        }
    }

In the view:

    <form action="{{ path('new') }}" method="post" {{ form_enctype(form) }}>
<div class="actions">
          <input type="submit" value="OK"/>
        </div>

But I receive nothing from the form. Someone can help me please ? This really weird bug.

I also had the same issue with the form handling.

The solution is to clear the cache manually and warm up it again.

php app/console cache:clear ==> Does'nt work for me, so I do:
rm -rf app/cache/dev
php app/console cache:warmup

That fix the problem!

But what was the issue? I figure out that 500 Internal Server Error get's thrown becaus it try's to load the cached routing values in app/cache/dev/annotations (in my case)

Hint: I have used annotation for templating and routing before in the controller. Than I've chang this and now I'm using external file routing... And that was my pain... I've forgotten to clear the cache manually!!!