我正在開發使用Symfony和FOSRestBundle的API,並希望使用以下路線:空航線路徑
應用程序/配置/ routing.yml中
page:
prefix: /page
resource: "@PageBundle/Resources/config/routing.yml"
PageBundle /資源/配置/ routing.yml中
page_get:
path: /{id}
methods: GET
defaults:
_controller: PageBundle:Page:get
id: null
page_post:
path:/
methods: POST
defaults:
_controller: PageBundle:Page:post
同爲PUT和DELETE ...
當我打電話GET對/頁工作正常,但是當調用後用於/頁,我得到以下錯誤:
No route found for "POST /page": Method Not Allowed (Allow: GET, HEAD)
我需要調用的/頁/不是/頁,那麼它的工作原理...
我能做些什麼來爲不同的方法使用相同的空路徑?
對不起,我的英語不好。
你試過方法:['GET','POST' ]?這裏有一些點在yml部分http://symfony.com/doc/current/routing/requirements.html#adding-http-method-requirements –
這些方法正在工作,但沒有找到POST/page的路由,只有POST/page /。 而GET /頁面正常工作。 –