struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alireza Fattahi <>
Subject Showing Action Exception as Ajax Errors
Date Fri, 15 Nov 2013 09:03:02 GMT

We are using struts2 JSONValidationWithInterceptor. This interceptor grabs the errors from
validation and convert them to json message
How can we have same feature! An interceptor which grabs the action exceptions and serialize
them as json errors.

I try below interceptor. When an exception happens it works, when there are no errors and
I should pass {} to response it is not working!

String target=Action.NONE;
        try {
             return target;

        catch (BussinessException ex) {
            StringBuilder sb = new StringBuilder();
            sb.append("{ ");
            sb.append("\"errors\": [\"");
            sb.append("Bussiness Exception Happend");
            return Action.NONE;

~~Alireza Fattahi
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message