Struts2 Exception handling usage?

后端 未结 1 1359
无人及你
无人及你 2020-12-20 04:48

I have my Action class below in which getTspNameIdMap throws ReqMgmtException exception (custom exception).

public Str         


        
相关标签:
1条回答
  • 2020-12-20 05:42

    You should use exception handling mechanism in Struts2, that's what exception interceptor provides. Also you should handle exceptions in the action method like in your question. If it handles all exceptions good, if not the exception handler could handle it. Also in some methods which doesn't have throws Exception signature you can only catch the exception but cannot return ERROR result. So, rethrowing the exception and handling it by the interceptor is the workaround.

    References:

    • Exception handling in struts2 and hibernate
    • Which Exceptions to declare/handle in struts xml
    • Struts 2 what to do when user inserts action which does not exist
    • how to validate json being sent using struts2 json plugin without throwing exception
    0 讨论(0)
提交回复
热议问题