我尝试使用FOSRestBundle但收到错误:
No route found for "GET /en/users"
这是控制器动作:
public function getUsersAction()
{
return new Response('resting');
}
这是app / config / routin.yml中的配置:
geekhub_main:
resource: "@GeekhubMainBundle/Resources/config/routing.yml"
prefix: /{_locale}
requirements:
_locale: |uk|en
defaults: { _locale: en }
这是MainBundle / Resources / config / routing.yml
中的配置users:
type: rest
resource: Geekhub\MainBundle\Controller\UsersController
以下是其余的配置:
fos_rest:
format_listener: true
routing_loader:
default_format: json
view:
view_response_listener: true
formats:
json: true
xml: true
yml: true
路由调试显示:
get_users GET ANY ANY /{_locale}/users.{_format}
get_user GET ANY ANY /{_locale}/users/{slug}.{_format}
我做错了什么?
答案 0 :(得分:1)
您不需要包含您的格式吗?那么/en/users.json
?