当前位置:   article > 正文

SSH框架的简单增删改查_ssh框架增删改查

ssh框架增删改查

首先在项目的pom.xml中加入SSH所需要的配置

<!-- 完成SSH所需要的依赖及配置 -->
<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <!-- servelet的核心依赖 -->
    <dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>4.0.1</version>
			<scope>provided</scope>
	</dependency>
		
    <!-- hibernate框架 -->
    <dependency>
	    <groupId>org.hibernate</groupId>
	    <artifactId>hibernate-core</artifactId>
	    <version>5.2.10.Final</version>
	</dependency>
	
	
	<!-- 引入Spring核心库 -->
	<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
	
	 <!-- MySQL  -->
    <dependency>
	    <groupId>mysql</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>5.1.35</version>
	</dependency>

	<!-- 引入c3p0数据库连接池 -->
	<dependency>
	    <groupId>com.mchange</groupId>
	    <artifactId>c3p0</artifactId>
	    <version>0.9.5.2</version>
	</dependency>

	<!-- Spring整合Hibernate依赖 -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-orm</artifactId>
	    <version>4.3.10.RELEASE</version>
	</dependency>
	
	<!-- spring 的AspectJ依赖,解析事务切点 -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-aspects</artifactId>
	    <version>4.3.10.RELEASE</version>
	</dependency>
	
	
	<!-- 引入struts2依赖 -->
	<dependency>
	    <groupId>org.apache.struts</groupId>
	    <artifactId>struts2-core</artifactId>
	    <version>2.3.33</version>
	</dependency>
	
	<!-- struts2整合Spring的整合包 -->
	<dependency>
	    <groupId>org.apache.struts</groupId>
	    <artifactId>struts2-spring-plugin</artifactId>
	    <version>2.5.12</version>
	</dependency>
	
	<!-- log4j日志 -->
	<dependency>
	    <groupId>org.apache.logging.log4j</groupId>
	    <artifactId>log4j-core</artifactId>
	    <version>2.8.2</version>
	</dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79

StudentDao里面的内容

public interface StudentDao {
	//添加
   public void add(Student stu);
   //查
   public List<Student> select();
   
   //刪除
   
   public void delete(Student stu);
   
  //修改
   public void update(Student stu);
   
   //根據id查詢
   public Student byid(Student stu);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

studentdao的实现类StudentDaoImp

//定义一个sessionFactory
	private SessionFactory factory;
	public void add(Student stu) {
		factory.getCurrentSession().save(stu)
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/185274
推荐阅读
相关标签
  

闽ICP备14008679号