当按下回车键时,Spring 和 Vue.js 不支持请求方法 'POST'

Request method 'POST' not supported with Spring and Vue.js when enter key is pressed

我有这个问题。当我点击搜索按钮时,代码工作正常,但当我按下回车时,抛出 HttpRequestMethodNotSupportedException。我知道我没有 POST 控制器,但我在搜索按钮时不需要它。我缺少什么?

<form method="post" @keypress.enter="search">
        <div class="card mb-3">
            <div class="card-body">
                <div class="form-row">
                    <div class="form-group col-md-4 required">
                        <label for="id">Id</label>
                        <input type="text" v-model="model.id" name="id" id="id" class="form-control" maxlength="50" >
                    </div>
                </div>
                
                <button type="button" id="btnSearch" class="btn btn-primary" @click="search">
                    <i class="fa fa-search" aria-hidden="true"></i>
                    Search
                </button>
            </div>
        </div>
</form>

在您的 input 字段中添加属性 @keypress.enter.prevent