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)

目录
相关文章
|
27天前
|
前端开发 JavaScript Java
springboot图书馆管理系统前后端分离版本
springboot图书馆管理系统前后端分离版本
39 12
|
24天前
|
JavaScript NoSQL Java
基于SpringBoot+Vue实现的大学生就业服务平台设计与实现(系统源码+文档+数据库+部署等)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
63 6
|
24天前
|
JavaScript Java 测试技术
基于Java+SpringBoot+Vue实现的车辆充电桩系统设计与实现(系统源码+文档+部署讲解等)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
55 6
|
24天前
|
JavaScript NoSQL Java
基于SpringBoot+Vue的班级综合测评管理系统设计与实现(系统源码+文档+数据库+部署等)
✌免费选题、功能需求设计、任务书、开题报告、中期检查、程序功能实现、论文辅导、论文降重、答辩PPT辅导、会议视频一对一讲解代码等✌
40 4
|
24天前
|
JavaScript NoSQL Java
基于SpringBoot+Vue实现的大学生体质测试管理系统设计与实现(系统源码+文档+数据库+部署)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
37 2
|
1月前
|
存储 安全 Java
Spring Boot 3 集成Spring AOP实现系统日志记录
本文介绍了如何在Spring Boot 3中集成Spring AOP实现系统日志记录功能。通过定义`SysLog`注解和配置相应的AOP切面,可以在方法执行前后自动记录日志信息,包括操作的开始时间、结束时间、请求参数、返回结果、异常信息等,并将这些信息保存到数据库中。此外,还使用了`ThreadLocal`变量来存储每个线程独立的日志数据,确保线程安全。文中还展示了项目实战中的部分代码片段,以及基于Spring Boot 3 + Vue 3构建的快速开发框架的简介与内置功能列表。此框架结合了当前主流技术栈,提供了用户管理、权限控制、接口文档自动生成等多项实用特性。
81 8
|
24天前
|
JavaScript NoSQL Java
基于SpringBoot+Vue实现的冬奥会科普平台设计与实现(系统源码+文档+数据库+部署)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
41 0
|
3月前
|
XML Java 数据库连接
SpringBoot集成Flowable:打造强大的工作流管理系统
在企业级应用开发中,工作流管理是一个核心组件,它能够帮助我们定义、执行和管理业务流程。Flowable是一个开源的工作流和业务流程管理(BPM)平台,它提供了强大的工作流引擎和建模工具。结合SpringBoot,我们可以快速构建一个高效、灵活的工作流管理系统。本文将探讨如何将Flowable集成到SpringBoot应用中,并展示其强大的功能。
639 1
|
3月前
|
JavaScript Java 项目管理
Java毕设学习 基于SpringBoot + Vue 的医院管理系统 持续给大家寻找Java毕设学习项目(附源码)
基于SpringBoot + Vue的医院管理系统,涵盖医院、患者、挂号、药物、检查、病床、排班管理和数据分析等功能。开发工具为IDEA和HBuilder X,环境需配置jdk8、Node.js14、MySQL8。文末提供源码下载链接。
|
3月前
|
JavaScript NoSQL Java
CC-ADMIN后台简介一个基于 Spring Boot 2.1.3 、SpringBootMybatis plus、JWT、Shiro、Redis、Vue quasar 的前后端分离的后台管理系统
CC-ADMIN后台简介一个基于 Spring Boot 2.1.3 、SpringBootMybatis plus、JWT、Shiro、Redis、Vue quasar 的前后端分离的后台管理系统
90 0