• SSH环境搭建,配置整合初步(一)


    1,新Webproject。并把编码设为utf-8(全部的都是uft8数据库也是,就不会乱码了)
    2。加入框架环境
    Junit
    Struts2
    Hibernate 
    Spring
    3,整合SSH
    Struts2与Spring整合
    Hibernate与Spring整合
    4。资源分类
    5,配置日志




    Struts2
    jar包
    struts.xml, web.xml
    Hibernate
    jar包:核心包, 必须包, jpa, c3p0, jdbc
    hibernate.cfg.xml, *.hbm.xml
    Spring
    jar包
    appicationContext.xml/beans.xml




    声明一个bean

    (在bean/xml文件加入 

    <!-- 自己主动扫描与装配bean -->

    <context:component-scan base-package="你的包名"></context:component-scan>)


    @Component("beanName")
    @Controller
    @Service
    @Repository


    配置bean的scope
    @Scope("prototype")


    注入bean
    @Resource




    Spring与Struts2整合
    1,在web.xml中配置Spring的监听器
    2,加一个jar包


    Hibernate与Spring整合
    1。管理SessionFactory实例(仅仅须要一个)
    2,声明式事务管理




    Spring
    IOC 管理对象..
    AOP 事务管理..




    代码:
    boolean needLog = ConfigFile.getBooleanValue("needLog");


    if( needLog ){
    System.out.println("xxx");  // System.err.println("");
    }


    配置文件(mylog.properties)
    needLog = true/false




    slf4j
    JDK logging --> logging.properties
    Log4j       --> log4j.properties
    ...




    debug 调试信息
    info 一般信息
    warn 警告
    error 错误

    fatal 严重错误




    ================================================ 基本功能






    User, UserDao
    save(User user), update(), delete(), find(), ...
    Role, RoleDao
    save(Role role), update(), delete(), find(), ...
    Student, StudentDao
    save(Student student), update(), delete(), find(), ...
    ...




    BaseDao<T>
    save(T t), update(), delete(), find()


    UserDao extends BaseDao<User> { ... }
    RoleDao extends BaseDao<Role>{ ... }
    ...


  • 相关阅读:
    JSP 编码解说
    window系统之mongoDB安装,启动及如何设置为windows服务(总结)
    operator 安装
    JavaScript学习2
    JavaScript学习3
    win7的便签很好使
    COM技术内幕第九章笔记编程工作的简化
    VS乱码之UTF8篇
    必须而不是推荐尽量使用const引用参数
    查看不到网络连接(可以上网)
  • 原文地址:https://www.cnblogs.com/mqxnongmin/p/10704056.html
Copyright © 2020-2023  润新知