• spring_6ssh整合


    spring整合Hibernate

    整合目标

    1.由spring的Ioc容器生成hibernate的SessionFactory
    2.让hibernate使用spring的声明式事务

    spring整合Hibernate步骤

    1).先加入hibernate
    ①. jar包
    ②. 添加hibernate的配置文件hibernate.cfg.xml,并写相应配置
    ③. 编写持久化类对应的 .hbm.xml文件
    2).再加入Spring
    ①. jar包
    ②. 加入spring的配置文件,并进行配置
    配置数据源,并测试数据源getConnection()方法
    配置Hibernate的SessionFactory实例,测试数据源getConnection()会创建数据表
    配置Spring的声明式事务
    3).整合

    spring整合Struts2

    整合目标

    使 IOC 容器来管理 Struts2 的 Action。
    在spring配置文件中装配action类的bean,struts.xml中配置action的class属性指向bean的id。

    spring如何进行整合struts2 ?

    1.加入所需的jar包
    2.写好相应的业务层代码和jsp页面
    3.配置web.xml在原来的基础上加入的配置

      <!-- 配置spring配置文件的名称和位置 -->
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
      </context-param>
      <!-- 启动Ioc容器的ServletContextListener -->
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>  
    

    4.配置spring的配置文件applicationContext.xml
    把action类放入Ioc容器中

        <!-- 注意:在Ioc容器中配置Struts2的Action时,需要配置scope属性必须为prototype,即struts中action是非单例的 -->
        <bean id="personAction" 
            class="action.PersonAction" 
            scope="prototype">
            <property name="personService" ref="personServie"></property>
        </bean>  
    

    5.配置struts.xml文件
    action的class属性指向Ioc容器中的action类的bean的id

  • 相关阅读:
    Props属性
    逆卷积:convtranspose2d(fractionally-strided convolutions)
    nn.ReflectionPad2d(镜像填充)
    conv1*1的作用
    如何将jupyter中的.ipynb文件转换成python中的.py文件
    低光图像增强学习
    pytorch 中的variable函数
    BCELoss和BCEWithLogitsLoss
    正则化的理解
    网络压缩方法总结
  • 原文地址:https://www.cnblogs.com/TaogenJia/p/5468657.html
Copyright © 2020-2023  润新知