{
"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