A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© lsyt 初级黑马   /  2017-11-29 10:29  /  1098 人查看  /  2 人回复  /   1 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 小石姐姐 于 2017-11-29 16:20 编辑

## SSH(注解开发)
* 解决缓存问题openSessionInViewFilter(一定要在 Struts2 Filter 前配置)org.springframework.orm.hibernate5
.support.OpenSessionInViewFilter
* struts2的核心过滤器 org.apache.struts2.dispatcher.ng
.filter.StrutsPrepareAndExecuteFilter
* 开启扫描注解
    * context:component-scan base-package="包名"
### spring整合hibernate(由spring来管理hibernate的sessionFactory)
    * 在spring中提供一个localSessionFactory来加载hibernate的配置文件
    * 必须在web.xml中配置spring的ContextLoaderListener
   
    <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>

    * 配置连接池com.mchange.v2.c3p0.ComboPooledDataSource
    * 引入db.properties文件
        context:property-placeholder location="classpath:db.properties
    * 配置sessionFactory
        * property
            * dataSource
            * hibernateProperties()
                * prop(key:value)||value(key=value)
            * packagesToScan
                * list
                    * value(实体类包路径)
    * spring整合hibernate后DAO
        * 只需要DAO类继承hibernateDaoSupport,将sessionFactory注入Dao中,提供set方法(super.setSessionFactory(factory))
        * 增删改查 this.getHibernateTemplate().save/delete/update/find*
    * 事务管理
        * 事务管理器    org.springframework.orm.hibernate5
            .HibernateTransactionManager
        * 事务注解驱动 tx:annotation-driven
    * Service
        * 类上的注解
            * @Service("")
            * @Transactional
        * 注入Dao
            * @Autowire @Qualifier @Resource
### spring整合Struts2框架
* jsp页面form action=
    * ${pageContext.request.contextPath}/Action的value
* action
    * 类上的注解
        * @Controller
        * @Scope("prototype")
        * @NameSpace("/")
        * @ParentPackage("struts-default")
    * 注入service属性
        * @Autowire @Qualifier @Resource
    * 方法上的注解
        * @Action(value="jsp中action的value")
            * results={@result(name="",location="路径")}

2 个回复

倒序浏览
支持下楼主
回复 使用道具 举报
必须支持
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马