Spring-mvc controller and exception handling

后端 未结 5 1474
星月不相逢
星月不相逢 2021-02-09 08:35

Would like to ask you a best practice question where a spring-mvc controller is concerned. Please review the code below:

    @Autowired
    SomeService service;
         


        
5条回答
  •  不思量自难忘°
    2021-02-09 09:06

    Service class can/should throw exception.. You can handle those exception in controller for logging purpose..also you can show appropriate error pages on the basis of exception caught on controller..but that will be tedious.. better try spring exception handling..http://www.mkyong.com/spring-mvc/spring-mvc-exception-handling-example/

提交回复
热议问题