Java tutorial
/** * Copyright (c) 2005-2012 https://github.com/zhangkaitao * * Licensed under the Apache License, Version 2.0 (the "License"); */ package com.sishuok.chapter3.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import java.util.concurrent.Callable; /** * ? springmvc?? * <p>User: Zhang Kaitao * <p>Date: 13-7-16 ?9:19 * <p>Version: 1.0 */ @Controller public class ExceptionController { @RequestMapping("/exception") public Callable<String> exception() { return new Callable<String>() { @Override public String call() throws Exception { Thread.sleep(2L * 1000); throw new RuntimeException(""); } }; } @ExceptionHandler public ModelAndView exceptionHandler(RuntimeException e) { ModelAndView mv = new ModelAndView("exception"); mv.addObject("exception", e); return mv; } }