KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Does it make sense to have an annotated (@Controller) Abstract class in Spring MVC driven container, basically would like to place most of the reusable methods such as exception handlers in the Abstract class and extend that with the base class, so that don't have to repeat the same boilerplate code. For example. Abstract Controller Class: @Controller abstract class AbstractExternalController { @ExceptionHandler(NoSuchRequestHandlingMethodException.class) @ResponseStatus(value = HttpStatus.NOT_FOUND) public @ResponseBody ResponseModel handleNotFoundException() { final ResponseModel response = new ErrorModel(); response.setStatus("404"); response.setMessage("Resource Not Found"); return response; } ... } Base Controller Class @Controller class ExternalControllerXXX extends AbstractExternalController { ... }
Tags (comma-separated)
Save Edits
Cancel