锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品一区av,最近中文字幕免费mv2018在线,日本另类视频http://www.aygfsteel.com/frogfool/category/17595.html鍏冩ā鍨嬩嬌鑳?/description>zh-cnTue, 27 Feb 2007 20:20:58 GMTTue, 27 Feb 2007 20:20:58 GMT60ExceptionInterceptorhttp://www.aygfsteel.com/frogfool/archive/2006/11/22/82912.htmlfrogfoolfrogfoolWed, 22 Nov 2006 14:57:00 GMThttp://www.aygfsteel.com/frogfool/archive/2006/11/22/82912.htmlhttp://www.aygfsteel.com/frogfool/comments/82912.htmlhttp://www.aygfsteel.com/frogfool/archive/2006/11/22/82912.html#Feedback0http://www.aygfsteel.com/frogfool/comments/commentRss/82912.htmlhttp://www.aygfsteel.com/frogfool/services/trackbacks/82912.htmlpackage com.gxlu.common.web.webwork.intercepter;

import java.io.StringWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.gxlu.common.web.webwork.action.AjaxJSONAction;
import com.gxlu.common.web.webwork.action.AjaxUpdaterAction;
import com.gxlu.common.web.webwork.action.AjaxXMLAction;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.Action;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.Interceptor;

/**
聽* Interceptor to handle Exceptions thrown by Actions.
聽* <p>
聽* <a href="ExceptionHandlerInterceptor.java.html"> <i>View Source </i> </a>
聽* </p>
聽*聽
聽*/
public class ExceptionInterceptor implements Interceptor {
聽public static final String EXCEPTION = "exception";

聽protected final Log logger = LogFactory.getLog(getClass());

聽private Map exceptionMappings;

聽/**
聽 * Set the mappings between exception class names and result names.
聽 *
聽 * @param mappings
聽 *聽聽聽聽聽聽聽 fully qualified exception class names as keys, and result names as
聽 *聽聽聽聽聽聽聽 values
聽 */
聽public void setExceptionMappings(Properties mappings) throws ClassNotFoundException {
聽聽this.exceptionMappings = new HashMap();

聽聽for (Iterator it = mappings.keySet().iterator(); it.hasNext();) {
聽聽聽String exceptionClassName = (String) it.next();
聽聽聽String viewName = mappings.getProperty(exceptionClassName);
聽聽聽Class exceptionClass = Class.forName(exceptionClassName, true, Thread.currentThread().getContextClassLoader());
聽聽聽this.exceptionMappings.put(exceptionClass, viewName);
聽聽}
聽}

聽/**
聽 * Invoke action and if an exception occurs, route it to the mapped result.
聽 */
聽public String intercept(ActionInvocation invocation) throws Exception {
聽聽String result = null;

聽聽try {
聽聽聽result = invocation.invoke();
聽聽} catch (Throwable e) {
聽聽聽logger.error(e);
聽聽聽//
聽聽聽result = EXCEPTION;
聽聽聽//
聽聽聽StringWriter writer = new StringWriter();
聽聽聽e.printStackTrace(new java.io.PrintWriter(writer));
聽聽聽ServletActionContext.getRequest().setAttribute("_exception_stack_trace_", writer.toString());
聽聽聽ServletActionContext.getRequest().setAttribute("_exception_message_", e.getMessage());
聽聽聽writer = null;
聽聽聽Action action = invocation.getAction();
聽聽聽if(action instanceof AjaxJSONAction) {聽聽聽聽
聽聽聽聽return "exception.json";
聽聽聽} else if(action instanceof AjaxXMLAction) {
聽聽聽聽return "exception.xml";
聽聽聽} else if(action instanceof AjaxUpdaterAction) {
聽聽聽聽return "exception.updater";
聽聽聽}
聽聽聽/**
聽聽聽 * // check for specific mappings if (this.exceptionMappings !=
聽聽聽 * null) { for (Iterator it =
聽聽聽 * this.exceptionMappings.keySet().iterator(); it.hasNext();) {
聽聽聽 * Class exceptionClass = (Class) it.next(); if
聽聽聽 * (exceptionClass.isInstance(ex)) { result = (String)
聽聽聽 * this.exceptionMappings.get(exceptionClass); } } } if (null ==
聽聽聽 * result || "".equals(result)) { result = EXCEPTION; }
聽聽聽 */
聽聽}
聽聽return result;

聽}

聽public void destroy() {
聽}

聽public void init() {
聽}
}



frogfool 2006-11-22 22:57 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 绿春县| 万盛区| 晋宁县| 合阳县| 文昌市| 泰州市| 合作市| 潍坊市| 石屏县| 吕梁市| 原平市| 安丘市| 民县| 胶州市| 田阳县| 东莞市| 德州市| 衢州市| 蓝山县| 周口市| 嫩江县| 涿鹿县| 改则县| 淄博市| 馆陶县| 辽阳县| 宜良县| 定陶县| 高唐县| 禄劝| 老河口市| 锡林郭勒盟| 寿阳县| 龙山县| 澜沧| 奈曼旗| 怀宁县| 镇平县| 荥经县| 白银市| 阿鲁科尔沁旗|