如何解决laravel中的'MethodNotAllowedHttpException'错误?

I have got an error

MethodNotAllowedHttpException

when I am using 'post' in my route:

Route::post('SeeDetail', [
        'uses' => 'DataController@SeeDetail',
        'as' => 'SeeDetail'
        ]);

But, if I am using 'get' in my route, there's no error but I have a data_id in the link (localhost/survey/public/SeeDetail?data_id=1).
Do you know how to make the data_id disappear from the link (localhost/survey/public/SeeDetail)?

Button in my view like this:

<a href="{{ route('SeeDetail', ['data_id'=>$getData->data_id])}}" class="btn btn-default">

You send a get request not post request. You need to use get instead of post. But you also pass parameter in the URL but you don't specify in your route.

Try this:

Route::get('SeeDetail/{data_id}', [
    'uses' => 'DataController@SeeDetail',
    'as' => 'SeeDetail'
]);

Docs

In route, You have mensioned it as a post method. But you accessing as get method. If you want "post" method, try to use form, else mension the route as get instead of post.

As others have mentioned links use GET method, and thus if you define your route as POST Laravel cannot match it and throws MethodNotAllowedHttpException.

To pass some additional data in the request you can use POST method and form with hidden field.

<form method="POST" action="{{ route('SeeDetail') }}">
    {{ csrf_field() }}
    <input type="hidden" name="data_id" value="{{ $getData->data_id }}">
    <button type="submit" class="btn btn-default">Go</button>
</form>

However keep in mind that POST request should be used for data manipulation, after which browser is redirected to GET page. This way you will achieve fluid navigation without any "Confirm re-sending" dialogs and problems when user refreshes the page.