SpringBoot发送ajax请求后台执行了的到了数据但返回不到前端;前端报405错误

问题遇到的现象和发生背景

img

前端请求到了后台,后台第一次正常输出,第二次后端收到请求并且得到了数据,在返回是抛出“org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported”异常
运行结果及报错内容 后端:org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported;

前端:This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jan 04 17:00:28 CST 2022
There was an unexpected error (type=Method Not Allowed, status=405).

我的解答思路和尝试过的方法 :将@RequestMapping路径加上post请求的提交方式;在浏览器上输入我的后端路径是可以正常取到数据,但使用ajax第一次可以正常运行,第二次就报错
我想要达到的结果

那你不如直接把@requestMapping换成@postMapping呢,405应该是超时,还有就是可以在参数上加@requestparam注解

在requestMapping中加入method = RequestMethod.POST

@PostMapping