我有 2 条路线:
Route::post('/post_2', 'TestController@post_2')
->name('post_2');
Route::post('/result', 'TestController@result')
->name('result');
和 TestController 如下。
public function post_2(){
return view('post_2View');
}
public function result(\App\Http\Requests\Post_2Request $request){
return "Successful";
}
Post_2查看
<form action="{{route('result')}}" method="post">
{{ csrf_field() }}
<input type="text" name="checkValidate">
<input type="submit" value="Submit">
</form>
最后是请求验证 Post_2View 中的 checkValidate 输入
public function rules()
{
return [
'checkValidate'=>'required'
];
}
public function messages() {
return [
'checkValidate.required'=>"This field is required"
];
}
当我在 checkValidate 输入中有数据时,一切正常,但是当请求文件返回错误时,我在浏览器中看到错误
**
* Throw a method not allowed HTTP exception.
*
* @param array $others
* @return void
*
* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
*/
protected function methodNotAllowed(array $others)
{
throw new MethodNotAllowedHttpException($others);
}
请告诉我,我该如何解决。谢谢。