一、使用web技术处理(web.xml文件加入以下代码)
404 /404.jsp 500 /500.jsp
二、使用SpringMVC的异常处理
1.定义一个异常处理类,类前面加注解@ControllerAdvice
2.定义异常处理方法,方法前面加注解@ExceptionHandler
@ControllerAdvice
public class ExceptionAdvice {
@ExceptionHandler(ArithmeticException.class)
public String arithmetic(Exception e){
return "error/arithmetic";
}
}



