今天看b站视频学项目时跟着老师敲,在运行后登陆时报了一个Request method ‘POST’ not supported错误,多方查询无果,最终发现是我的thymeleaf配戳了,于是写了这篇文章告诉大家如何定位错误

1.既然是post请求出错,问题肯定是在提交表单的时候错了

在这里插入图片描述
注意查看method和action是否写对了

2.如果提交表单时没有出错,就看看自己controller层是否注释写错了

参考代码如下
在这里插入图片描述

3.也有可能是引用class类出了问题
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐