struts2 spring 拦截器无效
Java 代码:
/**
* 请求耗时处理
* @author yidanlin
*/
@Aspect
public class MethodTimeInterceptor {
private Logger logger = LoggerFactory.getLogger(MethodTimeInterceptor.class);
/**
* 拦截包下的action方法
*
*/
@Around("execution(* net.zkbc.p2p.mgt.action.*.*(..))")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
long starTime = System.currentTimeMillis();// 处理开始时间
String method = joinPoint.getSignature().getName();
logger.info("============> operator enter the method {}() begin with request param {}" ,method, JSON.toJSONString(joinPoint.getArgs()));
Object result = joinPoint.proceed();
long endTime = System.currentTimeMillis();// 处理结束时间
long useTime = endTime - starTime;
logger.info("<============ operator finish the method {}() end with response param {},处理耗时:{}毫秒" ,method, JSON.toJSONString(result),useTime);
return result;
}
}
struts.xml:
<?xml version="1.0"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts/struts-base.xml"/>
<include file="struts/struts-mgt.xml"/>
<include file="struts/struts-pay.xml"/>
<include file="struts/struts-custom.xml"/>
<include file="struts/struts-accounting.xml"/>
<include file="struts/struts-third-api.xml"/>
<constant name="struts.multipart.maxSize" value="35242880"/>
<constant name="struts.multipart.saveDir" value="/tmp"/>
<package name="nomal" extends="struts-default">
</package>
<package name="mgmt" extends="nomal">
<interceptors>
<interceptor-stack name="teamwareStack">
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="teamwareStack"/>
</package>
</struts>
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"
default-lazy-init="true">
<bean id="methodTimeInterceptor" class="net.zkbc.p2p.mgt.interceptor.MethodTimeInterceptor"></bean>
.................................
配置和代码如上,服务正常启动 但是不会调用拦截器代码。大侠帮忙看看,谢谢。