I have used the result type stream in my action method which depends on an ajax call. This ajax call is activated on focus out of a textfield on my JSP. The function of this A
The error is logical: if you return an error result, or an error mapped to an exception, you are still returning a success result, because the relative httpheader (statusCode) will always be 200
(Success).
It is an error only to you, the browser (and hence the jQuery callback function) can't know it is an error result.
To enter the request.fail(function( jqXHR, textStatus ) {
part, you need to send a different statusCode (4xx
or 5xx
), eg. 500
(Internal Server Error), otherwise you'll always enter the .done
To do this in Struts2, you can use:
the Struts2 JSON plugin returning the following result as described here:
<result name="error" type="json">
<param name="errorCode">500</param>
</result>
the Struts2 HttpHeader result. Due to an error, the documentation is not available right now; I've opened a JIRA ticket for it, meanwhile you can check the Javadoc:
<result name="error" type="httpheader">
<param name="error">500</param>
</result>