springboot整合jsp快速搭建增删改查的学生管理系统

简介: springboot整合jsp快速搭建增删改查的学生管理系统

接:[springboot 搭建简单demo](https://blog.csdn.net/qq_44969643/article/details/106408784)

**先看最终效果图:**



![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20200529130723586.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0OTY5NjQz,size_16,color_FFFFFF,t_70)

由于是jsp写的,所以效果不是很好(之前做过:vue-cli+Element ui+springboot的图书管理系统,比较美观,下载地址:[github](https://github.com/hnust-xijing/BookManage.git))



新建项目:

使用maven,选择webapp(jsp需要)

pom.xml


```java

<parent>

   <groupId>org.springframework.boot</groupId>

   <artifactId>spring-boot-starter-parent</artifactId>

   <version>2.0.7.RELEASE</version>

 </parent>


 <dependencies>

   <dependency>

<!-- web相关的组件-->

     <groupId>org.springframework.boot</groupId>

     <artifactId>spring-boot-starter-web</artifactId>

   </dependency>


<!--整合jsp-->

   <dependency>

     <groupId>org.springframework.boot</groupId>

     <artifactId>spring-boot-starter-tomcat</artifactId>

   </dependency>


   <dependency>

     <groupId>org.apache.tomcat.embed</groupId>

     <artifactId>tomcat-embed-jasper</artifactId>

   </dependency>

<!--JSTL-->

   <dependency>

     <groupId>jstl</groupId>

     <artifactId>jstl</artifactId>

     <version>1.2</version>

   </dependency>

 

   <dependency>

     <groupId>org.projectlombok</groupId>

     <artifactId>lombok</artifactId>

     <version>1.18.6</version>

     <scope>provided</scope>

   </dependency>

 </dependencies>

创建配置文件 application.yml

server:

 port: 8181

spring:

 mvc:

   view:

     prefix: /

     suffix: .jsp

```

**创建配置文件 application.yml**


```java

server:

 port: 8181

spring:

 mvc:

   view:

     prefix: /

     suffix: .jsp

```

**创建Handler**


```java

package com.shuang.controller;


import com.shuang.entity.Student;

import com.shuang.repository.StudentRepository;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.PostMapping;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;


@Controller

@RequestMapping("/hello")

public class HelloHandler {


   @Autowired

   private StudentRepository studentRepository;


   @GetMapping("/index")

   public ModelAndView index(){

       ModelAndView modelAndView=new ModelAndView();

       modelAndView.setViewName("index");

       modelAndView.addObject("List",studentRepository.findAll());

       return modelAndView;

   }

   @GetMapping("/deleteById/{id}")

   public String deleteById(@PathVariable("id") long id){

       studentRepository.deleteById(id);

           return "redirect:/hello/index";

   }


   @PostMapping("/save")

   public String save(Student student){

       studentRepository.saveOrUpdate(student);

       return "redirect:/hello/index";

   }

   @PostMapping("/update")

   public String update(Student student){

       studentRepository.saveOrUpdate(student);

       return "redirect:/hello/index";

   }

   @GetMapping("/findById/{id}")

   public ModelAndView findById(@PathVariable("id") long id){

      ModelAndView modelAndView=new ModelAndView();

      modelAndView.setViewName("update");

      modelAndView.addObject("student",studentRepository.findByid(id));

       return modelAndView;

   }

}

```

**JSP**

index.jsp

```java

<%--

 Created by IntelliJ IDEA.

 User: Administrator

 Date: 2020/5/29

 Time: 10:16

 To change this template use File | Settings | File Templates.

--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page isELIgnored="false"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>

<head>

   <title>Title</title>

</head>

<body>

   <h1>学生信息</h1>

   <table>

       <tr>

           <th>学生编号</th>

           <th>学生姓名</th>

           <th>学生年龄</th>

           <th>操作</th>

       </tr>

       <c:forEach items="${List}" var="student">

           <tr>

               <td>${student.id}</td>

               <td>${student.name}</td>

               <td>${student.age}</td>

               <td>

                   <a href="/hello/findById/${student.id}">修改</a>

                   <a href="/hello/deleteById/${student.id}">删除</a>

               </td>

           </tr>

       </c:forEach>

   </table>

   <a href="/save.jsp">添加学生</a>

</body>

</html>

```

save.jsp


```java

<%--

 Created by IntelliJ IDEA.

 User: Administrator

 Date: 2020/5/29

 Time: 12:01

 To change this template use File | Settings | File Templates.

--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>

<head>

   <title>Title</title>

</head>

<body>

  <form action="/hello/save" method="post">

      ID:<input type="text" name="id"/><br/>

      name:<input type="text" name="name"/><br/>

      age:<input type="text" name="age"/><br/>

      <input type="submit" name="提交"/>

  </form>

</body>

</html>

```

update.jsp


```java

<%--

 Created by IntelliJ IDEA.

 User: Administrator

 Date: 2020/5/29

 Time: 12:05

 To change this template use File | Settings | File Templates.

--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>

<head>

   <title>Title</title>

</head>

<body>

<form action="/hello/update" method="post">

   ID:<input type="text" name="id" value="${student.id}" readonly/><br/>

   name:<input type="text" name="name" value="${student.name}"/><br/>

   age:<input type="text" name="age" value="${student.age}"/><br/>

   <input type="submit" name="提交"/>

</form>

</body>

</html>

```

**文件目录**

![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20200529130604962.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0OTY5NjQz,size_16,color_FFFFFF,t_70)

目录
相关文章
|
11天前
|
安全 Java API
SpringBoot + 事务钩子函数,打造高效支付系统!
【8月更文挑战第9天】在当今快速发展的数字支付时代,构建一个稳定、高效且安全的支付系统是企业数字化转型的关键一步。SpringBoot以其简洁的配置、快速的开发速度以及强大的生态支持,成为了构建支付系统的热门选择。而结合事务钩子函数(Transaction Hooks),则能进一步确保支付流程的完整性、一致性和可维护性。以下,我将分享如何利用SpringBoot与事务钩子函数来打造高效支付系统的技术实践。
39 15
SpringBoot + 事务钩子函数,打造高效支付系统!
|
1天前
|
Java 微服务 Spring
SpringBoot+Vue+Spring Cloud Alibaba 实现大型电商系统【分布式微服务实现】
文章介绍了如何利用Spring Cloud Alibaba快速构建大型电商系统的分布式微服务,包括服务限流降级等主要功能的实现,并通过注解和配置简化了Spring Cloud应用的接入和搭建过程。
SpringBoot+Vue+Spring Cloud Alibaba 实现大型电商系统【分布式微服务实现】
|
1天前
|
NoSQL JavaScript 前端开发
SpringBoot+Vue实现校园二手系统。前后端分离技术【完整功能介绍+实现详情+源码】
文章介绍了如何使用SpringBoot和Vue实现一个校园二手系统,采用前后端分离技术。系统具备完整的功能,包括客户端和管理员端的界面设计、个人信息管理、商品浏览和交易、订单处理、公告发布等。技术栈包括Vue框架、ElementUI、SpringBoot、Mybatis-plus和Redis。文章还提供了部分源代码,展示了前后端的请求接口和Redis验证码功能实现,以及系统重构和模块化设计的一些思考。
SpringBoot+Vue实现校园二手系统。前后端分离技术【完整功能介绍+实现详情+源码】
|
5天前
|
XML JSON Java
使用IDEA+Maven搭建整合一个Struts2+Spring4+Hibernate4项目,混合使用传统Xml与@注解,返回JSP视图或JSON数据,快来给你的SSH老项目翻新一下吧
本文介绍了如何使用IntelliJ IDEA和Maven搭建一个整合了Struts2、Spring4、Hibernate4的J2EE项目,并配置了项目目录结构、web.xml、welcome.jsp以及多个JSP页面,用于刷新和学习传统的SSH框架。
14 0
使用IDEA+Maven搭建整合一个Struts2+Spring4+Hibernate4项目,混合使用传统Xml与@注解,返回JSP视图或JSON数据,快来给你的SSH老项目翻新一下吧
|
5天前
|
Java 数据库连接 mybatis
基于SpringBoot+MyBatis的餐饮点餐系统
本文介绍了一个基于SpringBoot和MyBatis开发的餐饮点餐系统,包括系统的主控制器`IndexController`的代码实现,该控制器负责处理首页、点餐、登录、注册、订单管理等功能,适用于毕业设计项目。
12 0
基于SpringBoot+MyBatis的餐饮点餐系统
|
6天前
|
供应链 前端开发 Java
JSP+servlet+mybatis+layui服装库存管理系统(大三上学期课程设计)
这篇文章通过一个服装库存管理系统的实例,展示了在Spring Boot项目中使用Ajax、JSON、layui、MVC架构和iframe等技术,涵盖了注册登录、权限管理、用户管理、库存管理等功能,并提供了系统运行环境和技术要求的详细说明。
JSP+servlet+mybatis+layui服装库存管理系统(大三上学期课程设计)
|
1月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的武汉市公交路线查询系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的武汉市公交路线查询系统的详细设计和实现(源码+lw+部署文档+讲解等)
|
1月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的旅游攻略系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的旅游攻略系统的详细设计和实现(源码+lw+部署文档+讲解等)
|
1月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的大学生勤工助学管理系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的大学生勤工助学管理系统的详细设计和实现(源码+lw+部署文档+讲解等)
|
1月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的公交系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的公交系统的详细设计和实现(源码+lw+部署文档+讲解等)