symfony - _symfony 4 中的本地管理
问题描述
我尝试在我的路线中设置变量 {_local} ...这是控制器
/*
* @Route("/{_locale}" , name="home" , requirements={"_locale": "en|fr"})
*/
public function generalHome($_locale)
{
dump($_locale) ;
return $this->render('customer/home/home.html.twig');
}
/en
当我在浏览器中输入网址时,
Symfony 返回错误:
No route found for "GET /en"
PS:我没有修改任何其他文件
解决方案
我可能是错的,但看起来你的路线没有找到。这可能是由于您的 routes.yml 未导入注释引起的:
# config/routes/annotations.yaml
controllers:
resource: '../../src/Controller/'
type: annotation
有关路由的更多信息
推荐阅读
- google-apps-script - 复制和插入行(带公式)A列有*的所有地方
- python-telegram-bot - 使用电报机器人发送文本和图像
- node.js - 使用请求承诺的 Node.js 嵌套回调不起作用
- python - 检索不属于XPATH、python selenium 的文本节点?
- html - CSS 代码最大宽度在 Internet 上发布时不起作用
- javascript - 是否可以使用脚本/函数模拟按钮单击?
- ios - Cordova 7.1.0:在 iOS 上启动后出现白屏
- java - 如何切换到框架并访问其中的元素?
- c++ - 即使线程是可连接的,程序也会终止调用线程连接
- forms - Symfony 2.8 表单必填字段错误文本