Exception handling in Struts 2 and Hibernate

后端 未结 2 1321
逝去的感伤
逝去的感伤 2021-01-16 15:06

Suppose that we have developed a website in Struts2, Hibernate, MySQL and we have added few try/catch blocks here are there which encloses database calls via Hi

2条回答
  •  情歌与酒
    2021-01-16 15:37

    The user doesn't need to know there was a database exception, the developer does.

    The specific exception should be logged. The user should see that an operation failed. Generally you'd either simply report this through normal S2 means, e.g., an error message.

    You may also throw an application-specific exception and use S2's declarative exception handling.

    You may use declarative exception handling to handle any or all low-level exceptions, but IMO that's either too general, or too tedious.

提交回复
热议问题