你是怎么配置Spring的AOP的?能把配置文件贴出来吗?
解决方案 »
- 同一个项目hibernate 就是查不出数据jdbc就可以查出
- 请问高手这是那几个lib包冲突了?
- jbpm4 源码 ,一段关于线程的代码,帮我分析一下.
- 简单分栏加密源码
- 请问数据库设计时,什么时候才用联合主键?
- 框架问题,高手帮忙看看
- struts 1.2 跳转 action 到另一个action
- svn的链接出错问题,知道的大神快点冒泡啊
- 菜鸟问题:搭建java web service环境server端和client端都需要那些组件?
- 求助:insert插入时,保报错,原因是在同一列中插入了2个相同的值并且用逗号隔开了
- 请大家帮忙解答
- 各位大侠!请问关于webshere6“不推荐使用资源 jdbc/wfmsds 的直接 JNDI 查找”的错误怎么解决,很急!还请各位高手百忙之中帮忙解决!先
//开启自动代理
<aop:aspectj-autoproxy/>
//部署一个测试action
<bean id="testAction" name="/test" class="com.abc.action.TestAction"/>
//部署一个切面类
<bean class="com.abc.action.ActionLayerAspect"/>
我是参照Spring2.0的官方参考手册一步步做的,就是找不出原因,迷茫中。
另外,现在Spring2.0的资料比较少,希望能找一个志同道合的朋友一起学习,
我的QQ:121440879
public class ActionLayerAspect{
.......
}
我现在在xml文件中配置AOP已经成功了:
<bean
id="actionLayerAspect"
class="com.abc.aspect.ActionLayerAspect"/>
<aop:config>
<aop:aspect ref="actionLayerAspect">
<aop:before
pointcut="execution(* com.abc.action.*Action.*(..))"
method="doPreAction"/>
</aop:aspect>
</aop:config>
但我就是不知道为什么用注释式的AOP就不行呢,好像编译器忽略了@Aspect
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="permissionCheckAdvice"
class="com.dybx.aop.PermissionCheckAdvice">
</bean> <aop:aspectj-autoproxy proxy-target-class="true" /></beans>permissionCheckAdvice的代码:@Aspect
public class PermissionCheckAdvice {
// @Before("execution(* com.dybx.iservice.IBidService.*(..))")
@Around("execution(* com.dybx.web.BidController.*(..))")
public Object invoke(ProceedingJoinPoint jointPoint) throws Throwable {
System.out.println("method starts..."
+ jointPoint.getSignature().getDeclaringTypeName() + "."
+ jointPoint.getSignature().getName());
System.out.println("..." + jointPoint.getArgs().length);
System.out.println("..." + jointPoint.getArgs()[1]); Object retVal = jointPoint.proceed(); System.out.println("method ends..."
+ jointPoint.getSignature().getDeclaringTypeName() + "."
+ jointPoint.getSignature().getName());
System.out.println("method ends..." + retVal);
return retVal;
}}
@Around("execution(* com.dybx.web.BidController.*(..))")中的BidController是一个控制器类,为什么不起效果呢?