当我在/ home页上时,看到“找不到页面”。
module77.info.yml
name: Module 77
type: module
core: 8.x
package: MyPackage
module77.routing.yml
module77.hellopage:
path: '/hello'
defaults:
_controller: '\Drupal\module77\Controller\MyController::helloWorld'
requirements:
_permission: 'view content'
src / Controller / MyController.php
<?php
/**
* @file
* Contains \Drupal\module77\Controller\MyController.
*/
namespace Drupal\module77\Controller;
use Drupal\Core\Controller\ControllerBase;
class MyController extends ControllerBase {
/**
* {@inheritdoc}
*/
public function helloWorld() {
$output = [];
$output['#title'] = 'HelloWorld page title';
$output['#markup'] = 'Hello World!';
return $output;
}
}
如何解决这个问题? (此处显示一些文字,因为stackoverflow不会比文字更喜欢代码)