ssh SSH的整合框架及增删改查操作实例练习

整体的框架目录


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"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">

    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/Test?characterEncoding=utf-8">
        </property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQL5InnoDBDialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <!--  
        <property name="mappingLocations" value="classpath:*.hbm.xml" />
        -->
        <property name="mappingResources">
            <list>
                <value>
                    com/it/model/entity/persist/Classes.hbm.xml
                </value>
                <value>
                    com/it/model/entity/persist/Students.hbm.xml
                </value>
            </list>
        </property>
    </bean>

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <tx:annotation-driven transaction-manager="transactionManager" />
    <bean id="studentsDao" class="com.it.model.dao.StudentsDao">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    
    <bean id="studentsService" class="com.it.model.service.Impl.StudentsServiceImpl">
        <property name="studentsDao" ref="studentsDao"></property>
    </bean>
    <bean name="indexAction" class="com.it.web.controller.IndexController">
        <property name="studentsService" ref="studentsService"></property>
    </bean>
</beans>

struts.xml的配置内容:

hibernate.cfg.xml文件的配置内容:




hibernate.reveng.xml文件的配置内容:


Classes.hbm.xml文件及Students.hbm.xml文件的配置内容:







上面框架的配置内容基本完成,以下是代码的实体类及。。。


配置漏了web.xml的配置  不好意思  在这里补上:

web.xml文件的配置:

下面是jsp页面的展示:


以上就是ssh的实例  有更好的代码记得留言评价  感谢


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值