我有 Symfony 路由問題。即使我在兩個(gè)不同路由的路徑中使用了不同的參數(shù),Symfony 也將其識別為一個(gè)模式并指向路由文件中首先定義的路徑。例如:app_restaurants_inner: path: /london-restaurants/{id}/{restaurant_name}.html defaults: { _controller: AppBundle:Restaurants:inner}app_restaurants_by_cuisine: path: /london-restaurants/cuisine/{cuisine}.html defaults: { _controller: AppBundle:Restaurants:index}第一個(gè)路由加載一個(gè)特定的餐廳,參數(shù)是 id 和餐廳名稱。餐廳名稱僅包含 az、0-9 和連字符。在第二個(gè)參數(shù)中,只有一個(gè)參數(shù)是美食。但是,當(dāng)我嘗試加載美食(第二條路線)時(shí),它會(huì)將我引導(dǎo)至與美食路徑相似的餐廳路徑。另一方面,以下路線也被標(biāo)識為類似于餐廳的路徑。app_restaurants_by_cuisine_letter: path: /london-restaurants/cuisine/{cuisine}-{letter}.html defaults: { _controller: AppBundle:Restaurants:index}單詞“cuisine”標(biāo)識為“{id}”,“{cuisine}-{letter}”標(biāo)識為“{restaurant_name}”。我怎樣才能解決這個(gè)問題?
1 回答

ibeautiful
TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
app_restaurants_inner:
path: /london-restaurants/{id}/{restaurant_name}.html
defaults: { _controller: AppBundle:Restaurants:inner}
requirements:
id: '\d+'
app_restaurants_by_cuisine:
path: /london-restaurants/cuisine/{cuisine}.html
defaults: { _controller: AppBundle:Restaurants:index}
- 1 回答
- 0 關(guān)注
- 209 瀏覽
添加回答
舉報(bào)
0/150
提交
取消