Show pageBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Spring RestController Better Error Handling ====== Instead of returning the plain old Java object in the mapping method, we can use return a ResponseEntity<T> object. For exmaple: <code> @GetMapping("/") public ResponseEntity<Book> index() { try { Book b = bookService.editBookName(1); return ResponseEntity.ok(b); } catch (Exception e) { e.printStackTrace(); return ResponseEntity.status(HttpStatus.CONFLICT).body(null); } } </code> springboot/spring_restcontroller_better_error_handling.txt Last modified: 2020/05/28 15:22by chongtin