1:通过扫描的形式来实现注解。
2:action不用配置。
3:bean不用配置
4:bean自动注入到action

解决方案 »

  1.   

    SSH框架
    1、applicationContext.xml中添加以下代码可以实现
     <!-- 使用 context:component-scan 
                让Bean定义注解工作起来  
                且
                隐式地在内部注册了AutowiredAnnotationBeanPostProcessor和CommonAnnotationBeanPostProcessor -->
        <!-- Spring支持以下4种类型的过滤方式   此种是通过正则表达式过滤一些类  -->
        <!-- base-package属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理-->
    <context:component-scan base-package="service,dao,entity,log">
    <context:include-filter type="regex"
    expression="service\.*" />
    <context:include-filter type="regex"
    expression="dao\.*" />
    <context:include-filter type="regex"
    expression="entity\.*" />
    </context:component-scan>
    2、web.xml中加入以下代码可实现
    <filter>
    <filter-name>struts2Filter</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2Filter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
      

  2.   

    你意思用注解是吧?
    packageToscan