Spring、Hibernate、Struts

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  11 Posts :: 0 Stories :: 6 Comments :: 0 Trackbacks

最近在使用BeanNameAutoProxyCreator对Struts的action里的方法进行拦截,记录每个方法的使用时间,配置文件如下:

<bean name="/query/usermanage" class="com.gfsoft.example.action.UserAction">
    
<property name="userService">
        
<ref bean="webquery.person.proxy"/>     
    
</property>    
</bean>


<!--  Interceptors -->
    
<bean name="logger"
        class
="com.gfsoft.example.interceptor.ProfilingInterceptor" />

    
<!-- AutoProxies -->
    
<bean name="loggingAutoProxy"
        class
="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        
<property name="beanNames">
            
<list>
             
<idref bean="/query/usermanage"/>
            
</list>
        
</property>
        
<property name="interceptorNames">
            
<list>
                
<value>logger</value>
            
</list>
        
</property>
    
</bean>

当我测试时,程序没问题,但是如果把Interceptors 和AutoProxies配置到另一个配置文件里,测试时,没有拦截action里的动作。疑问就是:难道必须把要拦截的bean和Interceptors AutoProxies配置在同一配置文件里吗?如果可以分开配置,应该如何写配置文件?

问题已解决:
    把Interceptors 和AutoProxies配置到另一个配置文件里pub-services.xml里,然后在需要拦截的action的配置文件里的最前面加上<import resource="../pub/pub-services.xml"/>即可。
posted on 2005-12-26 14:40 ahgf 阅读(3499) 评论(0)  编辑  收藏 所属分类: Spring

只有注册用户登录后才能发表评论。


网站导航: