1. <legend id='i7yX3'><style id='i7yX3'><dir id='i7yX3'><q id='i7yX3'></q></dir></style></legend>
  2. <i id='i7yX3'><tr id='i7yX3'><dt id='i7yX3'><q id='i7yX3'><span id='i7yX3'><b id='i7yX3'><form id='i7yX3'><ins id='i7yX3'></ins><ul id='i7yX3'></ul><sub id='i7yX3'></sub></form><legend id='i7yX3'></legend><bdo id='i7yX3'><pre id='i7yX3'><center id='i7yX3'></center></pre></bdo></b><th id='i7yX3'></th></span></q></dt></tr></i><div id='i7yX3'><tfoot id='i7yX3'></tfoot><dl id='i7yX3'><fieldset id='i7yX3'></fieldset></dl></div>
    <tfoot id='i7yX3'></tfoot>
  3. <small id='i7yX3'></small><noframes id='i7yX3'>

        <bdo id='i7yX3'></bdo><ul id='i7yX3'></ul>

    1. Symfony 2 使用 POST 重定向

      时间:2023-10-12

        <small id='qTAa1'></small><noframes id='qTAa1'>

        • <tfoot id='qTAa1'></tfoot>

              <tbody id='qTAa1'></tbody>
            <i id='qTAa1'><tr id='qTAa1'><dt id='qTAa1'><q id='qTAa1'><span id='qTAa1'><b id='qTAa1'><form id='qTAa1'><ins id='qTAa1'></ins><ul id='qTAa1'></ul><sub id='qTAa1'></sub></form><legend id='qTAa1'></legend><bdo id='qTAa1'><pre id='qTAa1'><center id='qTAa1'></center></pre></bdo></b><th id='qTAa1'></th></span></q></dt></tr></i><div id='qTAa1'><tfoot id='qTAa1'></tfoot><dl id='qTAa1'><fieldset id='qTAa1'></fieldset></dl></div>
                <bdo id='qTAa1'></bdo><ul id='qTAa1'></ul>
              • <legend id='qTAa1'><style id='qTAa1'><dir id='qTAa1'><q id='qTAa1'></q></dir></style></legend>
              • 本文介绍了Symfony 2 使用 POST 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 Symfony 2 中,我的控制器中有以下代码:

                In Symfony 2 I have the following code in my Controller:

                // prepare to render the seller info panel
                $response = array(
                    'data' => $data,
                );
                
                // render the seller info panel
                return $this->redirect($this->generateUrl('route', $response));
                

                路线在哪里:

                route:
                    pattern:  /listing/complete/{data}
                    defaults: { _controller: FooBundle:Foo:action }
                    requirements:
                        _method:  POST
                

                这不起作用,因为重定向正在发出 GET 请求.我也试过这种模式,但它与路线不匹配:

                This doesn't work since the redirect is making a GET request. I've also tried it this pattern, but its not matching the route:

                route:
                    pattern:  /listing/complete
                    defaults: { _controller: FooBundle:Foo:action }
                    requirements:
                        _method:  POST
                

                我发现路由文档没有帮助.有没有办法让重定向发出 POST 请求?路线会是什么样子,我是否必须在控制器中执行任何操作才能使其发生?

                I've found the routing documentation unhelpful. Is there a way that I can have the redirect make a POST request? What would the route look like, and do I have to do anything in the controller to make it happen?

                推荐答案

                重定向 POST 请求是不可能的,因为浏览器必须重新发送 POST 数据(它不需要).在这种情况下,您应该做的是使用 转发.

                It's impossible to redirect a POST request because the browser would have to re-send the POST data (which it doesn't). What you should do instead in this case is use forwarding.

                这篇关于Symfony 2 使用 POST 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:使用 API PUT 请求上传文件 下一篇:如何在中间件中将用户对象绑定到请求

                相关文章

                1. <legend id='pNhSP'><style id='pNhSP'><dir id='pNhSP'><q id='pNhSP'></q></dir></style></legend>
                    <bdo id='pNhSP'></bdo><ul id='pNhSP'></ul>

                  1. <i id='pNhSP'><tr id='pNhSP'><dt id='pNhSP'><q id='pNhSP'><span id='pNhSP'><b id='pNhSP'><form id='pNhSP'><ins id='pNhSP'></ins><ul id='pNhSP'></ul><sub id='pNhSP'></sub></form><legend id='pNhSP'></legend><bdo id='pNhSP'><pre id='pNhSP'><center id='pNhSP'></center></pre></bdo></b><th id='pNhSP'></th></span></q></dt></tr></i><div id='pNhSP'><tfoot id='pNhSP'></tfoot><dl id='pNhSP'><fieldset id='pNhSP'></fieldset></dl></div>
                    <tfoot id='pNhSP'></tfoot>

                    <small id='pNhSP'></small><noframes id='pNhSP'>