struts2+spring+ibatis如何进行集成配置,那位大虾能把集成步骤及配置贴出来。。小弟感激不尽

解决方案 »

  1.   

    每一个框架的搭建方式都一样,提醒你一点可能会出错的地方:struts和spring整合需要一个jar包:struts-spring-plugin-2.1.1.0.jar
      

  2.   

    http://blog.csdn.net/peihexian/archive/2008/12/09/3486099.aspx
      

  3.   

    applicationContext.xml 配置--
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="date" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
    value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
    </property>
    <property name="url"
    value="jdbc:sqlserver://localhost:1433;databaseName=ST">
    </property>
    <property name="username" value="sa"></property>
    <property name="password" value="sasasa"></property>
    </bean>
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation" value="classpath:sqlMapConfig.xml"></property>
    <property name="dataSource" ref="date"></property>
    </bean>
    <bean id="dao" class="dao.PersonDaoImp">
    <property name="sqlMapClient" ><ref local="sqlMapClient"></ref></property>
    </bean>
    </beans>
    sqlMapConfig.xml 配置------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd" >
    <sqlMapConfig>
    <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" useStatementNamespaces="true"/>
    <sqlMap resource="bean/Person.xml" />
    </sqlMapConfig>web.xml 配置---
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
      </context-param>
      <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <filter>
       <filter-name>ff</filter-name>
       <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
      </filter>
      <filter-mapping>
       <filter-name>ff</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
    </web-app>其它的很简单啊,可自己搞定啊