You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

我的Laravel路由代码存在什么错误?student/store路由无法正常工作

Laravel路由冲突问题解析

问题代码

Route::get('student/{id}', 'StudentController@show');
Route::post('student/store', 'StudentController@store');

问题原因

student/store 路由几乎无法正常工作,核心原因是路由匹配优先级和可变参数的匹配范围:

  • 第一条路由的 student/{id} 包含可变参数 {id},该参数默认会匹配任意字符串内容
  • 当发起 student/store 的请求时,路由解析器会优先匹配到第一条路由,把store当作{id}的参数值传入StudentController@show,导致第二条路由永远不会被触发

内容的提问来源于stack exchange,提问作者someone

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 14:35:22