您的位置:首页 > Web前端

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

2018-01-17 10:53 627 查看

整体的框架目录





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文件的配置内容:





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





















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

web.xml文件的配置:





下面是jsp页面的展示:







以上就是ssh的实例  有更好的代码记得留言评价  感谢
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息