spring rest项目提示Request method 'PUT' not supported Method Not Allowed 405 错误

{
  "timestamp": "2019-04-28 17:43:07",
  "status": 405,
  "error": "Method Not Allowed",
  "message": "Request method 'PUT' not supported",
  "path": "/customer"
}

今天项目发布后,发现系统所有的  PUT请求不能用了, 提示如上,

本地测试正常,发布之后就不行了,瞬间很懵逼了

网上搜了一箩筐信息,发现好像都不对....

仔细看了一下代码,发现了问题

新版本增加了角色验证,角色不符合,跳转到403错误页

我的shiro配置:

       shiroFilterFactoryBean.setFilters(map);
        shiroFilterFactoryBean.setLoginUrl("/login");
        shiroFilterFactoryBean.setSuccessUrl("/index");
        shiroFilterFactoryBean.setUnauthorizedUrl("/home/error/403");
        LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
           filterChainDefinitionMap.put("/customer/login/**","anon");
        filterChainDefinitionMap.put("/upload/**","anon");
        filterChainDefinitionMap.put("/logback/**","anon");

  我的错误页这是这样的:

    @ApiOperation(value = "角色无权限", notes = "这是一个错误处理接口,不需要调试")
    @ApiIgnore
    @RequestMapping(value = "/error/403",method = RequestMethod.GET)
    public Result error403() {
        response.setStatus(403);
        return new Result("角色无权限", false);
    }

啊........... 原来是这样 

发布后的登陆角色没有权限,所以跳转到403页面  403页面只支持GET 所以报错..呵呵 

解决方法:  将403的页面  method去掉 不限制请求方式.如下

    @ApiOperation(value = "角色无权限", notes = "这是一个错误处理接口,不需要调试")
    @ApiIgnore
    @RequestMapping(value = "/error/403")
    public Result error403() {
        response.setStatus(403);
        return new Result("角色无权限", false);
    }

  

顺便说一下405错误码  :

405 errors often arise with the POST method. You may be trying to introduce some kind of input form on the Web site, but not all ISPs allow the POST method necessary to process the form.

All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP.

摘自

https://www.checkupdown.com/status/E405.html

 

转载于:https://www.cnblogs.com/niceletter/p/10785561.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值