SSH 통합

7207 단어 SSH 통합
struts-2.2.3.1  spring-framework-3.1.2  hibenate-3.6.7 통합.
Spring 연결 풀 의 설정 을 볼 수 있 습 니 다.JDBC,C3P 0,BoneCP,Proxool 이 있 습 니 다.http://blog.csdn.net/allen_gang/article/details/9067889
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
      <welcome-file> index.jsp</welcome-file>
   
  </welcome-file-list>
  
  
    <!--   spring    applicationContext.xml -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>    
  	<!--   spring        -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:beans.xml</param-value>
    </context-param>
  
 
   <!-- 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>  

  
</web-app>

bean.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"
       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-3.0.xsd
           http://www.springframework.org/schema/tx
	       http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
	       http://www.springframework.org/schema/aop
	       http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
           
	
	
 	<!--        bean  -->
	<!--
	<context:annotation-config />
	<context:component-scan base-package="com.peacemap" />
	-->
	
	<!--   PropertyPlaceholderConfigurer       -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<value>classpath:jdbc.properties</value>
		</property>
	</bean>
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName" value="${jdbc.driverClassName}" />
  <property name="url" value="${jdbc.url}" />
  <property name="username" value="${jdbc.username}" />
  <property name="password" value="${jdbc.password}" />
 </bean> 
   <!--    hibernate SessionFactory-->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="annotatedClasses">
			<list>
				<value>com.tech.allen.model.User</value>
				 
			</list>
		</property>
		
		
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.Oracle10gDialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
			</props>
		</property>
	</bean>
	
	<!--   HibernateTemplate -->
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	
	<!--
	<bean id="txManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	-->
	
	
	
	
	
	<!--          -->  
	
	<!--      -->
	<bean name="UserDao" class="com.tech.allen.dao.impl.UserDaoImpl">
		<property name="hibernateTemplate" ref="hibernateTemplate">
		</property>
	</bean>
	<bean name="UserService" class="com.tech.allen.service.impl.UserServiceImpl">
		<property name="UserDao" ref="UserDao"/>
		 
	</bean>
	
	<bean name="UserAction" class="com.tech.allen.action.UserAction">
		<property name="UserService" ref="UserService"/>
		 
	</bean>
	
 

</beans>

struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.objectFactory"
		value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
		<!--
	<constant name="struts.objectFactory.spring.autoWire" value="type"/>	
	<constant name="struts.objectFactory" value="spring"/>	
    <constant name="struts.devMode" value="false" />

   -->
   
   <package name="json" extends="struts-default">
   
 
      
      <!-- UserAction  -->
       <!--                  -->
 
        <action name="getUserList" class="UserAction" method="getUserList">
           <result name="success" >success.jsp</result>
          
        </action>
        
 
       </package>
     
 

</struts>

필요 한 jar 파일http://download.csdn.net/detail/allen_gang/5560593
 
 

좋은 웹페이지 즐겨찾기