(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException)
| 220 | return new AccessDeniedHandler(){ |
| 221 | |
| 222 | @Override |
| 223 | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) |
| 224 | throws IOException, ServletException { |
| 225 | if (!response.isCommitted()) { |
| 226 | //向Header头写入信息 |
| 227 | response.setHeader("message", UriUtils.encode(accessDeniedException.getMessage(),"UTF-8"));//不支持中文参数 用UriUtils.encode代替URLEncoder.encode,解决空格转换成+号的问题 |
| 228 | response.sendError(HttpStatus.FORBIDDEN.value(),//返回403错误 |
| 229 | HttpStatus.FORBIDDEN.getReasonPhrase());//错误信息 |
| 230 | |
| 231 | } |
| 232 | |
| 233 | } |
| 234 | |
| 235 | }; |
| 236 | } |
nothing calls this directly
no test coverage detected