为什么我明明用的 post,结果提示 get 不可用???
blade模版
<div class="form-group" id="vaptchaContainer">
<form action="{{ route('verifiCode') }}" class="form-group" method="POST" accept-charset="utf-8">
@csrf
<input type="hidden" name="verification_key" value="{{ $verification_key }}">
<input class="form-control form-control-lg text-center" id="verificode" name="verificode" placeholder="#" maxlength="4" type="tel" min="4" autocomplete="off" value="">
<button type="submit" class="btn btn-lg btn-primary text-dark mt-3 with-out-phone" disabled="disabled">请输入验证码</button>
</form>
</div>
controller
public function verifiCode(UserRequest $request) {
rentrun('123');
}
request
<?php
namespace App\Http\Requests;
class UserRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'verification_key' => 'required|string',
'verification_code' => 'required|string',
];
}
public function attributes()
{
return [
'verification_key' => '短信验证码 key',
'verification_code' => '短信验证码',
];
}
public function messages()
{
return [
'verification_key.required' => 'key不能为空',
'verification_code.required' => '验证码不能为空'
];
}
}
route
.
.
.
Route::post('/verifiCode', 'VerificationCodesController@verifiCode')->name('verifiCode');
.
.
.
错误提示
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.
post路由get怎么用? 你要2个都能用 得用 any
看下请求的url,有没有可能是请求的 url 是 http 开头的,服务器配置了http 强制跳转 https 导致请求变成 get
@Fantastic match 会好点吧