`
ZhouGang库鲁卡
  • 浏览: 28630 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

SSH框架整合

 
阅读更多

 

                                                       步骤

 

1,导入需要的包

      

2,配置配置文件

      (在ssh框架中,我们会把hibernate和struts交给spring处理!)

         @1,web.xml的配置

                 配置Spring监听器

                  

<listener>
    <description>Spring core configuration</description>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

                配置Struts过滤器

<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>*.action</url-pattern>
  </filter-mapping>

          

           @2配置Spring的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"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName"
			value="com.mysql.jdbc.Driver">
		</property>
		<property name="url" value="jdbc:mysql://localhost:3306/myssh">
		</property>
		<property name="username" value="root"></property>
		<property name="password" value="123"></property>
	</bean>
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<!-- if use the hibernate.cfg.xml as dataSource configuration, cancel the annotations -->
		<!-- remove other properties and dataSource bean. -->
		<!-- 
		<property name="configLocation" value="classpath:hibernate.cfg.xml" />
		 -->
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>com/hzboy/orm/Userinfo.hbm.xml</value>
			</list>
		</property>
	</bean>
</beans>

 

                  @3配置Struts.xml

在里面加上

<constant name="struts.objectFactory" value="spring" />

 

3,版本控制

 

       日过是我们自己导入的java库  那么可能会有版本冲突  纳闷尽量使用心得版本;或者自己下载以后整理好一套库  

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics