This commit is contained in:
Phillip Webb
2019-04-11 13:39:26 -07:00
parent dabe75a281
commit 2dfd916c96
34 changed files with 517 additions and 451 deletions

View File

@@ -20,8 +20,10 @@ import sample.tomcat.service.HelloWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class SampleController {
@@ -32,7 +34,12 @@ public class SampleController {
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();
throw new RuntimeException("Fail");
}
@ExceptionHandler(RuntimeException.class)
public ModelAndView handle(RuntimeException ex) {
return null;
}
}