Suppose there's a Double
variable in an action, and if the value sent in the request body is something like
{"dblField":""}
and the interceptorStack
looks like :
<action name="save" class="actions.MyAction" method="save">
<interceptor-ref name="jsonValidationWorkflowStack">
</interceptor-ref>
<!--<interceptor-ref name="loginStack"/>-->
<!-- I've tried using each of the above two separately, but both failed -->
<interceptor-ref name="json">
<param name="enableSMD">true</param>
</interceptor-ref>
<result type="json" name="*">
<param name="excludeProperties">
idIo
</param>
</result>
</action>
Then the action throws a NumberFormatException
, which is fine according to the plugin source code here.
But this exception is not handled in the plugin and hence, returns from the action throwing exception, which results in the firing of global-exception-handler
.
If the same request was sent using a query-string, ?dblField=
then the action returns INPUT
.
So, how can I make the json-plugin behave in the same way to return INPUT
and set appropriate fieldErrors
instead of throwing NumberFormatException
and firing the globalExceptionHandler
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…