//SpringMVC-servlet.xml配置方法拦截器居体内容的类
<bean id="controllerLog" class="cn.com.tiza.hjwulian.system.common.interceptor.ControllerLogInterceptor" />
<!-- 方法拦截器(拦截Controller包中的所有被RequestMapping注解的方法) MethodInterceptor -->
<aop:config proxy-target-class="true">
<aop:pointcut id="controllerMethodPointcut" expression="execution(* cn.com.tiza.hjwulian.system.action..*(..)) and
@annotation(org.springframework.web.bind.annotation.RequestMapping)"/>
<aop:advisor advice-ref="controllerLog" pointcut-ref="controllerMethodPointcut" />
</aop:config>
//拦截器具体内容
public class ControllerLogInterceptor implements MethodInterceptor {//实现spring方法拦截器接口---居体内容自定义
@Resource(name="txManager")
private DataSourceTransactionManager transactionManager;
@Override
public Object invoke(MethodInvocation args) throws Throwable {
LoginInfo userInfo = null;
String methodName = args.getMethod().getName();
String rtnTypeName = args.getMethod().getReturnType().getSimpleName();
BaseModel result = getRtnTypeObj(rtnTypeName);
//是否登录都可操作 忘记密码 发送验证码 不做拦截
if("forgetPassword".equals(methodName) || "sendPhoneForCode".equals(methodName)){
Object resultObject = args.proceed();
return resultObject;
}