Add exception message to json response:
[url]http://stackoverflow.com/questions/4033502/add-exception-message-to-json-response[/url][quote]Another option is to create a custom result type that both sets a 500 ISE status and returns a JSON response containing the error data. Then just map your exception to that result type in your struts.xml (just as you mapped it to the httpheader type in your example above).
Yet another option is to create an annotation for your Struts action methods that you intend to invoke via AJAX. Then, subclass the standard ExceptionMappingInterceptor and if the action method is annotated as @AjaxRequest (or whatever you call it), then you return a standard JSON response that contains the exception information. Otherwise, you fall through to the default behavior of mapping the result to some sort of page or result.
Personally, I prefer the latter approach.[/quote]
Ajax.Request如何捕获异常?
[url]http://www.iteye.com/topic/19517[/url]
扩展JQuery Ajax请求错误机制,实现服务器端消息回馈:
[url]http://www.cnblogs.com/lyk831216/archive/2009/04/24/1442791.html[/url]
[url]http://stackoverflow.com/questions/4033502/add-exception-message-to-json-response[/url][quote]Another option is to create a custom result type that both sets a 500 ISE status and returns a JSON response containing the error data. Then just map your exception to that result type in your struts.xml (just as you mapped it to the httpheader type in your example above).
Yet another option is to create an annotation for your Struts action methods that you intend to invoke via AJAX. Then, subclass the standard ExceptionMappingInterceptor and if the action method is annotated as @AjaxRequest (or whatever you call it), then you return a standard JSON response that contains the exception information. Otherwise, you fall through to the default behavior of mapping the result to some sort of page or result.
Personally, I prefer the latter approach.[/quote]
Ajax.Request如何捕获异常?
[url]http://www.iteye.com/topic/19517[/url]
扩展JQuery Ajax请求错误机制,实现服务器端消息回馈:
[url]http://www.cnblogs.com/lyk831216/archive/2009/04/24/1442791.html[/url]