zoukankan      html  css  js  c++  java
  • 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

     

  • 相关阅读:
    阶段5 3.微服务项目【学成在线】_day02 CMS前端开发_10-webpack研究-安装nodejs
    ES6深入浅出-1 新版变量声明:let 和 const-2.视频 let和const
    ES6深入浅出_汇总贴
    ES6深入浅出-1 新版变量声明:let 和 const-1.视频 概述
    数据类型及其空间大小,vs2012实测
    linux cmd
    常见英文地址表达方法
    网络基础
    VMware三种链接方式
    Source Insight使用技巧
  • 原文地址:https://www.cnblogs.com/niceletter/p/10785561.html
Copyright © 2011-2022 走看看