ssh框架整合

   

 

Web工程创建后。

1、添加hibernate支持(无需处理hibernate的配置文件)

2、添加spring支持(SessionFactoryjdbcjdo

3、添加的struts支持(添加springplusin插件包)

4、修改web.xml配置文件:

<context-param>

        <param-name>contextConfigLocation</param-name>

        <param-value>classpath:applicationContext.xml</param-value>

  </context-param> 

  <listener>

    <listener-class>

    org.springframework.web.context.ContextLoaderListener

    </listener-class>

  </listener>

 

5、修改applicationContext.xml配置文件

<beanname="dataSource"class="org.apache.commons.dbcp.BasicDataSource">

    <propertyname="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>

    <propertyname="url" value="jdbc:oracle:thin:@localhost:1521/oracle10"></property>

    <propertyname="username" value="bankvip"></property>

    <propertyname="password" value="bankvip"></property>

    <propertyname="maxActive" value="100"></property>

    <propertyname="maxIdle" value="30"></property>

    <propertyname="maxWait" value="500"></property>

    <propertyname="defaultAutoCommit" value="true"></property>

</bean>

 

    <beanid="sessionFactory"

        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

       <propertyname="dataSource"ref="dataSource"></property>

       <propertyname="hibernateProperties">

           <props>

              <propkey="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>

              <propkey="show_sql">true</prop>

              <propkey="format_sql">true</prop>    

           </props>

       </property>

      

    </bean>

6、部署工程,测试web是否能够部署成功,且tomcat启动正常

7、利用hibernate reverse Engneering实现RàE反转

 

8、创建web工程的相关包,并实现业务逻辑

Springàactionàservice(serviceImpl)àuserdao(userdaoImpl)àbean(*.hbm.xml)àdb

9、编写spring配置文件:applicationContext.xml

orm的管理文件:

<propertyname="mappingResources">

           <list>

              <value>com/workit/bean/BranchBean.hbm.xml</value>

              <value>com/workit/bean/DeptBean.hbm.xml</value>

              <value>com/workit/bean/MenusBean.hbm.xml</value>

              <value>com/workit/bean/RoleBean.hbm.xml</value>

              <value>com/workit/bean/PowerBean.hbm.xml</value>

              <value>com/workit/bean/UserBean.hbm.xml</value>

             

           </list>

       </property>

配置各个依赖bean

<beanid="userdao"class="com.workit.dao.Impl.UserDaoImpl">

    <propertyname="sessionFactory" ref="sessionFactory"></property>

</bean>

 

<beanid="userservice" class="com.workit.service.Impl.UserServiceImpl">

    <propertyname="userdao" ref="userdao"></property>

</bean>

 

<beanid="useraction" class="com.workit.action.UserAction">

    <propertyname="userservice" ref="userservice"></property>

</bean>   

整个文件内容如下:

<?xmlversion="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">

 

<beanname="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

    <propertyname="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>

    <propertyname="url" value="jdbc:oracle:thin:@localhost:1521/oracle10"></property>

    <propertyname="username" value="bankvip"></property>

    <propertyname="password" value="bankvip"></property>

    <propertyname="maxActive" value="100"></property>

    <propertyname="maxIdle" value="30"></property>

    <propertyname="maxWait" value="500"></property>

    <propertyname="defaultAutoCommit" value="true"></property>

</bean>

 

    <beanid="sessionFactory"

        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

       <propertyname="dataSource"ref="dataSource"></property>

       <propertyname="hibernateProperties">

           <props>

              <propkey="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>

              <propkey="show_sql">true</prop>

              <propkey="format_sql">true</prop>    

           </props>

       </property>

       <propertyname="mappingResources">

           <list>

              <value>com/workit/bean/BranchBean.hbm.xml</value>

              <value>com/workit/bean/DeptBean.hbm.xml</value>

              <value>com/workit/bean/MenusBean.hbm.xml</value>

              <value>com/workit/bean/RoleBean.hbm.xml</value>

              <value>com/workit/bean/PowerBean.hbm.xml</value>

              <value>com/workit/bean/UserBean.hbm.xml</value>

             

           </list>

       </property>

    </bean>

<beanid="userdao" class="com.workit.dao.Impl.UserDaoImpl">

    <propertyname="sessionFactory" ref="sessionFactory"></property>

</bean>

 

<beanid="userservice" class="com.workit.service.Impl.UserServiceImpl">

    <propertyname="userdao" ref="userdao"></property>

</bean>

 

<beanid="useraction" class="com.workit.action.UserAction">

    <propertyname="userservice" ref="userservice"></property>

</bean>      

   

</beans>

 

10、编写struts.xml配置文件

<struts>

    <includefile="struts-default.xml"></include>

    <packagename="workit" extends="struts-default">

       <actionname="UserAction_*"class="useraction"method="{1}">

           <resultname="loginsucc">/main.jsp</result>

           <resultname="failer">/index.jsp</result>

          

       </action>

   

    </package>

</struts>   

注意:class的值应该是有spring配置actionbeanid的值

11、部署发布。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值