ajax:Add exception message to json response

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]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值