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

     

  • 相关阅读:
    2、Qt Project之鼠标事件监控
    1、Qt Project之基本文件打开与保存
    Qt界面设计基础
    基于Keil软件的MCU环境搭建
    一次性将word中的数字和字母全部改为“Times New Roman”字体
    PAT 1004 Counting Leaves
    PAT 1003 Emergency
    DevC++ 控制台项目初始代码修改方法
    Win7在命令提示符(cmd.exe)中如何进行复制、粘贴工作
    VMware虚拟机如何在后台运行,后台运行怎么设置其在电脑右下角显示托盘图标
  • 原文地址:https://www.cnblogs.com/niceletter/p/10785561.html
Copyright © 2011-2022 走看看