filter抛出异常
时间: 2023-10-21 14:27:19 浏览: 233
Filter可以抛出异常,但是需要注意的是,Filter中抛出的异常并不会被@RestControllerAdvice或@ExceptionHandler(Exception.class)等全局异常处理机制捕获和处理。因为Filter的执行策略是在执行Controller之前执行的,所以Filter抛出的异常需要在Filter内部进行处理。在Filter的异常处理方法中,可以使用try-catch块来捕获异常,然后根据业务需求进行处理。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [Filter中抛出异常的处理](https://blog.csdn.net/qq_31854907/article/details/118765509)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [JavaWeb中URL重写用Forward方式并使其后filter可以拦截内部转发](https://download.csdn.net/download/yy417168602/10445381)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文