HttpRequestMethodNotSupportedException: Request method ‘GET‘ not supported]

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的时候,也正常过,现在不知道怎么就不可以了,欢迎讨论!!

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值