his application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Nov 25 11:39:36 CST 2020
There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'GET' not supported
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:213) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:422) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:367) at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.getHandlerInternal(RequestMappingInfoHandlerMapping.java:110) at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.getHandlerInternal(RequestMappingInfoHandlerMapping.java:59) at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:395) at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1234) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1016) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
查询没有问题,增删改均出现这个问题。
网上各种讲各种方法的都有,都不顶用,心想是不是 @RequestMapping 没有用好的问题,直到遇到这篇文章 @RequestMapping用法详解
里面讲到@RequestMapping 的method 属性
在实际应用中,很多人并没有按照这个规范做,因为使用GET/POST同样可以完成PUT和DELETE操作,甚至GET也可以完成POST操作,因为GET不需要用到表单,而POST却需要通过表单来发送。
由于在 RequestMapping 注解类中 method() 方法返回的是 RequestMethod 数组,所以可以给 method 同时指定多个请求方式,
如:@RequestMapping(path = "/login", method={RequestMethod.POST,RequestMethod.GET})
于是,在原来的Method方式的基础上,都写成了数组的形式,添加了RequestMethod.GET,问题解决!!
但是,有个问题,之前没添加RequestMethod.GET的时候,也正常过,现在不知道怎么就不可以了,欢迎讨论!!