Magento2: redict issue in router.php submiting post form

Source: Internet
Author: User
Tags magento2

I created a custom form when I tried to commit. It will go to my customRouter.php

Application \ code \ custom \ module \ controller \ router.php

HTTP//Local Host/Magento2/custom/job/reply/

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]    );}

The following provides errors.

1 Exception (S): Exception #0 (logicexception): Front controller achieves 100 router-matching iterations

For the other simple list of pages, it is rediction with the post form to fine the only problem.

I have joined a small job for example, it can help you.

Application \ code \ vendor \ module \ and 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__);

\ program \ code \ vendor \ module \ etc \ 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>

\ program \ code \ vendor \ module \ etc \ frontend \ 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>

\ program \ code \ vendor \ module \ etc \ frontend \ 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>

\ program \ code \ Vendor \ module \ controller \ 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->setmod Ulename (' 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]); }    }

In order to test I have forwarded to the CMS page that I have tested with my custom controller.

$ request-> Setmodulename ("CMS")-> Setcontrollername ("page")-> Setactionname (' View ')-> SetParam (' page_id ', 4);

Magento2: redict issue in router.php submiting post form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.