定义一个异常处理类TestErrorController:
@Controller
public class TestErrorController {
@RequestMapping("/exception")
public ModelAndView exception(ModelAndView view) throws ClassNotFoundException {
view.setViewName("index");
throw new ClassNotFoundException("class not found");
}
@RequestMapping("/nullpointer")
public ModelAndView nullpointer(ModelAndView view) {
view.setViewName("index");
String str = null;
str.length();
return view

最低0.47元/天 解锁文章
6万+

被折叠的 条评论
为什么被折叠?



