目录
内容:全局捕获一些没有被catch到的异常,进行统一处理
自定义一个异常 NotFoundException.java
public class NotFoundException extends Exception{
public NotFoundException(String message) {
super(message);
}
}
跳转至错误页面
Controller类中(逻辑处理时没有使用到try catch,而是直接throws异常)
@RestController
@RequestMapping("exception")
public class ExceptionController extends AbstractController{
@Autowired
private UserOrderService userOrderService;
//不用try catch 而是直接throws出异常
//订单详情
@RequestMapping(value = "info", method = RequestMethod.GET)
@ResponseBody
public BaseResponse info(@RequestParam String orderNo) throws NotFoundException, Exception{
if(StringUtils.isBlank(orderNo)){