struts2+sring4+mybatis3集成框架(一)

 

     struts2.3.24、spring4.1.6、mybatis3.3集成框架:

 

     1.log4j

     2.junit

     3.quartz

     4.ehcache

     5.spring IOC

     6.spring AOP @Aspect 面向切面编程

 

     首先,mybatis与spring集成,配置dataSource,配置SqlSessionFactory

     然后,struts2与spring集成,配置struts.xml:

     <package name="default" extends="struts-default">
        <interceptors>
            <interceptor-stack name="crudStack">
                <interceptor-ref name="checkbox" />
                <interceptor-ref name="params" />
                <interceptor-ref name="staticParams" />
                <interceptor-ref name="defaultStack" />
            </interceptor-stack>
        </interceptors>

        <default-action-ref name="showcase" />


        <action name="login" class="cn.web.action.LoginAction" method="login">
            <result name="success">/index.jsp</result>
        </action>

    </package>

 

   web.xml:

   配置过滤器:

   <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
 
  <!-- 
  <context-param>
   <param-name>log4jConfigLocation</param-name>
   <param-value>classpath:log4j.properties</param-value>
  </context-param>
  -->
  <listener>
   <listener-class>
    org.springframework.web.context.ContextLoaderListener
   </listener-class>
  </listener>
 
  <filter>
   <filter-name>struts2</filter-name>
   <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>*.do</url-pattern>
  </filter-mapping>
 
  <filter>
   <filter-name>struts2-cleanup</filter-name>
   <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
  </filter>
  <filter-mapping>
   <filter-name>struts2-cleanup</filter-name>
   <url-pattern>*.do</url-pattern>
  </filter-mapping>

 

 注意: spring插件的jar包是否一致

 

你可能感兴趣的:(struts2+sring4+mybatis3集成框架(一))