How to validate JSON being sent using Struts2 Json Plugin without throwing exception

六眼飞鱼酱① 提交于 2019-11-30 23:16:48

You could place exception interceptor before your own interceptor instead of the json interceptor by extending json interceptor and override intercept method where you can catch errors. Then you can either add action errors or rethrow a custom exception which you can map in the action config or globally.

<exception-mapping exception="org.exceptionmapping.CustomException"
                             result="errorresult"/>

This way you can map all json only interceptor errors with your custom exception.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!