Magento2:在Router.php Submiting POST表單Redict問題

來源:互聯網
上載者:User

標籤:

我建立自訂表格單,當我試圖提交。它會去我的自訂Router.php

應用程式\代碼\自訂\模組\控制器\ Router.php

HTTP://本地主機/ magento2 /自訂/職位/回複/

if (strpos($request->getServer(‘REQUEST_URI‘), ‘reply‘) !== false) {     $request->setModuleName(‘module‘)->setControllerName(‘posts‘)->setActionName(‘reply‘);    return $this->actionFactory->create(                    ‘Magento\Framework\App\Action\Forward‘, [‘request‘ => $request]    );}

以下提供錯誤。

1例外(S):異常#0(LogicException):前端控制器達到100路由器匹配的迭代

對於其他的簡單羅列網頁,它與POST表單rediction精唯一的問題。

我已經加入小型工作例如,它可以協助你。

應用程式\代碼\供應商\模組\和registration.php

<?php/** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */\Magento\Framework\Component\ComponentRegistrar::register(    \Magento\Framework\Component\ComponentRegistrar::MODULE,    ‘Vendor_Module‘,    __DIR__);

\程式\代碼\供應商\模組\等\ module.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">    <module name="Vendor_Module" setup_version="2.0.0"></module></config>

\程式\代碼\供應商\模組\等\前端\ routes.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">    <router id="standard">        <route id="sometest" frontName="sometest">            <module name="Vendor_Module" />        </route>    </router></config>

\程式\代碼\供應商\模組\等\前端\ di.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">    <type name="Magento\Framework\App\RouterList">        <arguments>            <argument name="routerList" xsi:type="array">                <item name="sometest" xsi:type="array">                    <item name="class" xsi:type="string">Vendor\Module\Router</item>                    <item name="disable" xsi:type="boolean">false</item>                    <item name="sortOrder" xsi:type="string">1</item>                </item>            </argument>        </arguments>    </type></config>

\程式\代碼\供應商\模組\控制器\ Router.php

 <?php    namespace Vendor\Module\Controller;    class Router implements \Magento\Framework\App\RouterInterface    {        protected $actionFactory;        protected $_response;        public function __construct(            \Magento\Framework\App\ActionFactory $actionFactory,            \Magento\Framework\App\ResponseInterface $response        ) {            $this->actionFactory = $actionFactory;            $this->_response = $response;        }        public function match(\Magento\Framework\App\RequestInterface $request)        {            //$request->setModuleName(‘module‘)->setControllerName(‘test‘)->setActionName(‘test‘);$request->setModuleName(‘cms‘)->setControllerName(‘page‘)->setActionName(‘view‘)->setParam(‘page_id‘, 4);            return $this->actionFactory->create(                ‘Magento\Framework\App\Action\Forward‘,                [‘request‘ => $request]            );        }    }

為了測試我已經轉寄到連我與我的定製控制器測試了CMS頁面。

$請求 - > setModuleName(“CMS”) - > setControllerName(“頁”) - > setActionName(‘查看‘) - > setParam(‘PAGE_ID‘,4);

Magento2:在Router.php Submiting POST表單Redict問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.