SSH框架的搭建

<?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>
 
    <!-- 配置struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
   <!-- 將spring配置讀入到servletContext中 -->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
   /WEB-INF/classes/config/spring/spring.xml
  </param-value>
 </context-param>

 <!-- 監聽器 -->
 <listener>
  <listener-class>
   org.springframework.web.context.ContextLoaderListener
  </listener-class>
 </listener>

 

 <!-- 配置過濾器 避免懶加載異常 -->
 <filter>
  <filter-name>hibernateFilter</filter-name>
  <filter-class>
   org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
  </filter-class>
 </filter>
 <filter-mapping>
  <filter-name>hibernateFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 


 <!-- 處理亂碼 -->
 <filter>
  <filter-name>Spring character encoding filter</filter-name>
  <filter-class>
   org.springframework.web.filter.CharacterEncodingFilter
  </filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>utf-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>Spring character encoding filter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 org.springframework.web.context.ContextLoaderListener
 <!-- 配置JSTL標籤 -->
 <jsp-config>
    <taglib>
       <taglib-uri>http://www.ibeifeng.com/oa/bfoa</taglib-uri>
       <taglib-location>/WEB-INF/bf.tld</taglib-location>
    </taglib>
 </jsp-config>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
 <!-- 掃描 -->
 <context:component-scan base-package="com.bf"></context:component-scan>
 <!-- 配置數據源 -->
 <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName"
   value="com.mysql.jdbc.Driver">
  </property>
  <property name="url" value="jdbc:mysql://localhost/bfoa"></property>
  <property name="username" value="root"></property>
  <property name="password" value="root"></property>
  <!-- 數據連接池初始值-->
  <property name="initialSize" value="1"></property>
  <!-- 數據連接池最大值 -->
  <property name="maxActive" value="300"></property>
  <!-- 數據連接池 最大空閒值-->啊啊
  <property name="maxIdle" value="2"></property>
  <!-- 數據連接池 最小空閒值-->
  <property name="minIdle" value="1"></property>
 </bean>
 
 <!-- 配置 sessionFactory -->
 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  
  <property name="dataSource" ref="dataSource" />
  
  <property name="configLocation">
   <value>classpath:config/hibernate/hibernate.cfg.xml</value>
  </property>
  
  <property name="mappingResources">
   <list>
    <value>config/hibernate/hbm/User.hbm.xml</value>
    <value>config/hibernate/hbm/Dep.hbm.xml</value>
    <value>config/hibernate/hbm/Emp.hbm.xml</value>
    <value>config/hibernate/hbm/Module.hbm.xml</value>
    <value>config/hibernate/hbm/Group.hbm.xml</value>
    <value>config/hibernate/hbm/Impower.hbm.xml</value>
   </list>
  </property>
  
  <property name="hibernateProperties">
   <value>
       hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    hibernate.hbm2ddl.auto=update
   </value>
  </property>
 </bean>
 
 <!-- 配置事務管理器 -->
 <bean id="txManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>
 
 <tx:annotation-driven transaction-manager="txManager"/>
 

 <bean id="depAction" class="com.bf.action.dep.DepAction"></bean>
 <bean id="empAction" class="com.bf.action.emp.EmpAction"></bean>
 <bean id="modAction" class="com.bf.action.mod.ModAction"></bean>
 <bean id="grpAction" class="com.bf.action.group.GroupAction"></bean>
 <bean id="userAction" class="com.bf.action.user.UserAction"></bean>
 <bean id="impowerAction" class="com.bf.action.impower.ImpowerAction"></bean>
 
 <bean id="isf" class="com.bf.serviceimpl.impower.ImpowerServiceFinderImpl"></bean>
 
 <bean id="ck" class="com.bf.common.CheckOption">
    <property name="isf" ref="isf"></property>
 </bean>
</beans>

 

發佈了33 篇原創文章 · 獲贊 4 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章