/* ================================================================== * Created [2009-4-27 下午11:32:55] by Jon.King * ================================================================== * TSS * ================================================================== * mailTo:jinpujun@hotmail.com * Copyright (c) Jon.King, 2009-2012 * ================================================================== */ package com.jinhe.tss.component.support.web.webwork; import javax.servlet.http.HttpServletResponse; import com.jinhe.tss.core.exception.ExceptionEncoder; import com.jinhe.tss.core.sso.context.Context; import com.opensymphony.xwork.Action; import com.opensymphony.xwork.ActionInvocation; import com.opensymphony.xwork.interceptor.Interceptor; /** * <p> * CatchExceptionInterceptor.java * </p> * 该拦截器截获Action产生的所有的异常,并以数据流方式将异常信息返回给客户端。 * */ public class CatchExceptionInterceptor implements Interceptor { private static final long serialVersionUID = -4301377671254468885L; public void destroy() { } public void init() { } /** * 拦截异常,处理错误信息 */ public String intercept(ActionInvocation actionInvocation) throws Exception { String result = Action.NONE; HttpServletResponse response = Context.getResponse(); try { result = actionInvocation.invoke(); } catch (Exception t) { ExceptionEncoder.encodeException(response, t); } return result; } }