<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
-->package org.roadway.wisp.zd.util;
import org.apache.log4j.Logger;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
/**
* @author Huyvanpull
*
*/
@SuppressWarnings("serial")
public class ExceptionInterceptor extends AbstractInterceptor
{
private Logger logger = Logger.getLogger(ExceptionInterceptor.class);
private String interceptorName;
@Override
public String intercept(ActionInvocation invocation) throws Exception
{
this.logger.debug("进入" + this.getInterceptorName());
String result = null;
try
{
result = invocation.invoke();
}
catch (Exception exception)
{
this.logger.error(this.getExceptionInfo(exception));
throw exception;
}
return result;
}
private String getExceptionInfo(Exception exception)
{
StringBuffer bExceptionInfo = new StringBuffer();
bExceptionInfo.append(exception.toString());
bExceptionInfo.append("\n\t");
StackTraceElement[] stackTraceElements = exception.getStackTrace();
for (int i = 0; i < stackTraceElements.length; i++)
{
bExceptionInfo.append("[" + this.getInterceptorName() + "] "
+ stackTraceElements[i].toString() + "\n\t");
}
return bExceptionInfo.toString();
}
public String getInterceptorName()
{
return interceptorName;
}
public void setInterceptorName(String interceptorName)
{
this.interceptorName = interceptorName;
}
}
分享到:
相关推荐
简单的struts2自定义拦截器 很适合web初学者
Struts2全局、局部自定义拦截器源码。
struts2自定义拦截器.pdf
Struts2自定义拦截器实现防止重复提交
strut2 配置自定义拦截器 包括struts2.xml 和 action对应的xml 以及拦截器 可能有点简单 但是基本配置都有
JSP 开发之Struts2内建自定义拦截器.docx
NULL 博文链接:https://llxhna.iteye.com/blog/1067851
由于struts2标签的性能不好,项目组决定不使用,但是如果用struts2自带的拦截器防止重复提交又必须struts标签,所以只好自定拦器实现
综合使用servlet filter与struts2 interceptor对权限进行验证。
本篇文章主要介绍了struts2自定义拦截器的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
此实例实现功能:用户需要指定用户名登陆, 登陆成功进入相应页面执行操作,否则返回到登陆页面进行登陆, 当直接访问操作页面(登陆后才能访问的页面)时则不允许,须返回登陆页面。
主要给大家介绍了关于Struts2学习基础教程之拦截器机制与自定义拦截器的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Struts2_自定义拦截器 struts2_3500_my_interceptor
struts2的自定义拦截器代码
struts2 用拦截器 实现用户权限登录 可以直接运行,只单单用到struts的东西。
struts2的自定义拦截器代码例子
主要介绍了JSP 开发之Struts2内建自定义拦截器的相关资料,需要的朋友可以参考下
自定义拦截器的实现以及拦截器的详细配置,配置文件里面有特别详细的注释,希望对刚接触拦截器的同学有帮助