最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

springboot實現(xiàn)學(xué)生管理系統(tǒng)

 更新時間:2022年07月25日 14:13:27   作者:沉河不浮  
這篇文章主要為大家詳細介紹了springboot實現(xiàn)學(xué)生管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了SpringBoot實現(xiàn)學(xué)生管理系統(tǒng),供大家參考,具體內(nèi)容如下

一、創(chuàng)建springboot項目

點擊下一步

點擊下一步,選擇要添加的依賴

點擊下一步,再點擊完成

修改pom.xml如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?? ?xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
?? ?<modelVersion>4.0.0</modelVersion>
?? ?<parent>
?? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ?<artifactId>spring-boot-starter-parent</artifactId>
?? ??? ?<version>2.6.7</version>
?? ??? ?<relativePath/> <!-- lookup parent from repository -->
?? ?</parent>
?? ?<groupId>com.young</groupId>
?? ?<artifactId>springboot04</artifactId>
?? ?<version>0.0.1-SNAPSHOT</version>
?? ?<name>springboot04</name>
?? ?<description>Demo project for Spring Boot</description>
?? ?<properties>
?? ??? ?<java.version>1.8</java.version>
?? ?</properties>
?? ?<dependencies>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ??? ?<artifactId>spring-boot-starter-thymeleaf</artifactId>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ??? ?<artifactId>spring-boot-starter-web</artifactId>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ??? ?<artifactId>spring-boot-starter-web-services</artifactId>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ??? ?<artifactId>spring-boot-starter-jdbc</artifactId>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.mybatis.spring.boot</groupId>
?? ??? ??? ?<artifactId>mybatis-spring-boot-starter</artifactId>
?? ??? ??? ?<version>2.1.0</version>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>mysql</groupId>
?? ??? ??? ?<artifactId>mysql-connector-java</artifactId>
?? ??? ??? ?<scope>runtime</scope>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ??? ?<artifactId>spring-boot-starter-test</artifactId>
?? ??? ??? ?<scope>test</scope>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.webjars</groupId>
?? ??? ??? ?<artifactId>jquery</artifactId>
?? ??? ??? ?<version>3.3.1</version>
?? ??? ?</dependency>
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.webjars</groupId>
?? ??? ??? ?<artifactId>bootstrap</artifactId>
?? ??? ??? ?<version>4.0.0</version>
?? ??? ?</dependency>
?? ?</dependencies>

?? ?<build>
?? ??? ?<plugins>
?? ??? ??? ?<plugin>
?? ??? ??? ??? ?<groupId>org.springframework.boot</groupId>
?? ??? ??? ??? ?<artifactId>spring-boot-maven-plugin</artifactId>
?? ??? ??? ?</plugin>
?? ??? ?</plugins>
?? ?</build>

</project>

修改resources目錄下的application.yml,代碼如下

spring:
? thymeleaf:
? ? prefix: classpath:/templates/
? ? suffix: .html
? mvc:
? ? view:
? ? ? static-path-pattern: /static/**
? datasource:
? ? url: jdbc:mysql://localhost:3306/springboot?useSSL=false&serverTimezone=UTC
? ? username: root
? ? password: 3fa4d180
? ? driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
? mapper-locations: classpath:mapper/*.xml

我們在我們創(chuàng)建的目錄下,創(chuàng)建pojo軟件包,在該包下創(chuàng)建Student.java

public class Student {
? ? private Integer id;
? ? private String name;
? ? private String grade;
? ? private String major;
? ? public Integer getId() {
? ? ? ? return id;
? ? }
? ? public void setId(Integer id) {
? ? ? ? this.id = id;
? ? }
? ? public String getName() {
? ? ? ? return name;
? ? }
? ? public void setName(String name) {
? ? ? ? this.name = name;
? ? }
? ? public String getGrade() {
? ? ? ? return grade;
? ? }
? ? public void setGrade(String grade) {
? ? ? ? this.grade = grade;
? ? }
? ? public String getMajor() {
? ? ? ? return major;
? ? }
? ? public void setMajor(String major) {
? ? ? ? this.major = major;
? ? }
? ? @Override
? ? public String toString(){
? ? ? ? return "Student{id="+id+",name="+name+
? ? ? ? ? ? ? ? ",grade="+grade+",major="+major+
? ? ? ? ? ? ? ? "}";
? ? }
}

我們在創(chuàng)建一個mapper軟件包,創(chuàng)建StudentMapper接口

@Mapper
public interface StudentMapper {
? ? List<Student>listStudent();
? ? List<Student>queryStudentByValue(String value);
? ? int saveStudent(Student student);
? ? int deleteStudent(Integer id);
? ? int updateStudent(Student student);
}

創(chuàng)建一個service軟件包,創(chuàng)建StudentService

@Service
public class StudentService {
? ? @Autowired
? ? private StudentMapper studentMapper;
? ? public List<Student>listStudent(){
? ? ? ? return studentMapper.listStudent();
? ? }
? ? public List<Student>queryStudentByValue(String value){
? ? ? ? return studentMapper.queryStudentByValue(value);
? ? }
? ? public int saveStudent(Student student){
? ? ? ? return studentMapper.saveStudent(student);
? ? }
? ? public int deleteStudent(Integer id){
? ? ? ? return studentMapper.deleteStudent(id);
? ? }
? ? public int updateStudent(Student student){
? ? ? ? return studentMapper.updateStudent(student);
? ? }
}

創(chuàng)建一個controller軟件包,創(chuàng)建StudentController

@RestController
@RequestMapping("/student")
public class StudentController {
? ? @Autowired
? ? private StudentService studentService;
? ? @RequestMapping("/listStudent")
? ? public ModelAndView listStudent(){
? ? ? ? List<Student>studentList=studentService.listStudent();
? ? ? ? ModelAndView modelAndView=new ModelAndView();
? ? ? ? modelAndView.addObject("studentList",studentList);
? ? ? ? modelAndView.setViewName("/listStudent");
? ? ? ? return modelAndView;
? ? }
? ? @RequestMapping("/queryStudentByValue")
? ? public ModelAndView queryStudentByValue(String value){
? ? ? ? List<Student>studentList=studentService.queryStudentByValue(value);
? ? ? ? ModelAndView modelAndView=new ModelAndView();
? ? ? ? modelAndView.addObject("studentList",studentList);
? ? ? ? modelAndView.setViewName("/listStudent");
? ? ? ? return modelAndView;
? ? }
? ? @RequestMapping("/saveStudent")
? ? public ModelAndView saveStudent(Student student){
? ? ? ? ModelAndView modelAndView=new ModelAndView();
? ? ? ? studentService.saveStudent(student);
? ? ? ? modelAndView.setViewName("forward:/student/listStudent");
? ? ? ? return modelAndView;
? ? }
? ? @RequestMapping("/updateStudent")
? ? public ModelAndView updateStudent(Student student){
? ? ? ? ModelAndView modelAndView=new ModelAndView();
? ? ? ? studentService.updateStudent(student);
? ? ? ? modelAndView.setViewName("forward:/student/listStudent");
? ? ? ? return modelAndView;
? ? }
? ? @RequestMapping("/deleteStudent")
? ? public ModelAndView deleteStudent(Integer id){
? ? ? ? ModelAndView modelAndView=new ModelAndView();
? ? ? ? studentService.deleteStudent(id);
? ? ? ? modelAndView.setViewName("forward:/student/listStudent");
? ? ? ? return modelAndView;
? ? }
}

在resources目錄下,創(chuàng)建mapper目錄,在該目錄下,放入我們的StudentMapper.xml配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
? ? ? ? PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
? ? ? ? "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.young.springboot04.mapper.StudentMapper">
? ? <select id="listStudent" resultType="com.young.springboot04.pojo.Student">
? ? ? ? select * from student
? ? </select>
? ? <select id="queryStudentByValue" parameterType="string" resultType="com.young.springboot04.pojo.Student">
? ? ? ? select * from student
? ? ? ? where id like '%${value}%' or name like '%${value}%' or grade like '%${value}%'
? ? ? ? or major like '%${value}%'
? ? </select>
? ? <insert id="saveStudent" parameterType="com.young.springboot04.pojo.Student">
? ? ? ? insert into student
? ? ? ? values(#{id},#{name},#{grade},#{major})
? ? </insert>
? ? <delete id="deleteStudent" parameterType="int">
? ? ? ? delete from student
? ? ? ? where id=#{id}
? ? </delete>
? ? <update id="updateStudent" parameterType="com.young.springboot04.pojo.Student">
? ? ? ? update student
? ? ? ? set name=#{name},grade=#{grade},major=#{major}
? ? ? ? where id=#{id}
? ? </update>
</mapper>

在我們的static目錄下, 放入我們需要的css目錄,我這里用的是pio框架的css目錄
接著我們在templates目錄下創(chuàng)建listStudent.html,用于顯示內(nèi)容

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
? ? <meta charset="UTF-8">
? ? <title>學(xué)生列表</title>
? ? <meta name="viewport" content="width=device-width,initial-scale=1">
? <link rel="stylesheet" href="../static/css/pico.min.css" th:href="@{/css/pico.min.css}">
? <style>
? ? #bodyLeft{
? ? ? position:relative;
? ? ? width:66%;
? ? ? float:left;
? ? }
? ? #bodyRight{
? ? ? position:relative;
? ? ? width:29%;
? ? ? float:right;
? ? }
? ? #editForm{
? ? ? position:absolute;
? ? ? margin-top:5%;
? ? ? margin-left:35%;
? ? ? width:30%;
? ? ? background-color:white;
? ? ? z-index:1;
? ? ? border:1px solid black;
? ? ? modal:true;
? ? ? border-radius:5%;
? ? }
? </style>
? <script type="text/javascript" th:inlne="javascript">
? ? function editStudent(student){
? ? ? var id=student.id;
? ? ? var name=student.name
? ? ? var grade=student.grade
? ? ? var major=student.major
? ? ? var editForm=document.getElementById("editForm");
? ? ? editForm.style.display="block";
? ? ? editForm.innerHTML=
? ? ? "<form action='http://localhost:8080/student/updateStudent' method='post' style='width:80%;margin-left:10%;margin-top:10%;'>"+
? ? ? "<label for='name'>姓名<input type='text' id='name' value="+name+" name='name'></label>"+
? ? ? "<label for='grade'>年級<input type='text' id='grade' value="+grade+" name='grade'></label>"+
? ? ? "<label for='major'>專業(yè)<input type='text' id='major' value="+major+" name='major'></label>"+
? ? ? "<label for='id' style='display:none;'>學(xué)號<input type='text' id='id' value="+id+" name='id' hidden></label>"+
? ? ? "<input type='submit' value='修改'>"+
? ? ? "<button style='outline'><a th:href='@{/student/listStudent}' style='color:white;'>取消</a></button>"+
? ? ? "</form>";
? ? }
? </script>
</head>
<body>
? <!--隱藏的表單彈窗-->
<div id="editForm" style="display:none"></div>
<div class="container" style="margin-top:5%;">
? <div id="bodyLeft">
? ? <table role="grid">
? ? ? <tr>
? ? ? ? <th scope="col">學(xué)號</th>
? ? ? ? <th scope="col">姓名</th>
? ? ? ? <th scope="col">年級</th>
? ? ? ? <th scope="col">專業(yè)</th>
? ? ? ? <th scope="col">編輯</th>
? ? ? ? <th scope="col">刪除</th>
? ? ? </tr>
? ? ? <div th:each="student:${studentList}">
? ? ? ? <tr>
? ? ? ? ? <td scope="row" th:text="${student.id}">學(xué)號</td>
? ? ? ? ? <td th:text="${student.name}">姓名</td>
? ? ? ? ? <td th:text="${student.grade}">年級</td>
? ? ? ? ? <td th:text="${student.major}">專業(yè)</td>
? ? ? ? ? <td><a th:onclick="editStudent([[${student}]])" href="#">編輯</a></td>
? ? ? ? ? <td><a th:href="@{/student/deleteStudent(id=${student.id})}">刪除</a></td>
? ? ? ? </tr>
? ? ? </div>
? ? </table>
? </div>
? <div id="bodyRight">
? ? <form th:action="@{/student/saveStudent}" method="post">
? ? ? <label for="name">
? ? ? ? 姓名<input type="text" id="name" name="name" placeholder="請輸入姓名">
? ? ? </label>
? ? ? <label for="grade">
? ? ? ? 年級<input type="text" id="grade" name="grade" placeholder="請輸入年級">
? ? ? </label>
? ? ? <label for="major">
? ? ? ? 專業(yè)<input type="text" id="major" name="major" placeholder="請輸入專業(yè)">
? ? ? </label>
? ? ? <input type="submit" value="修改">
? ? </form>
? </div>
</div>
</body>
</html>

運行效果如下:

點擊編輯

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 使用@CacheEvict?多參數(shù)如何匹配刪除

    使用@CacheEvict?多參數(shù)如何匹配刪除

    這篇文章主要介紹了使用@CacheEvict?多參數(shù)如何匹配刪除,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • Java操作pdf的工具類itext的處理方法

    Java操作pdf的工具類itext的處理方法

    這篇文章主要介紹了Java操作pdf的工具類itext,iText是一種生成PDF報表的Java組件,通過在服務(wù)器端使用Jsp或JavaBean生成PDF報表,客戶端采用超鏈接顯示或下載得到生成的報表,需要的朋友可以參考下
    2022-04-04
  • 手把手教你實現(xiàn)Java第三方應(yīng)用登錄

    手把手教你實現(xiàn)Java第三方應(yīng)用登錄

    本文主要介紹了手把手教你實現(xiàn)Java第三方應(yīng)用登錄,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Java中的匿名內(nèi)部類小結(jié)

    Java中的匿名內(nèi)部類小結(jié)

    java內(nèi)部類分為: 成員內(nèi)部類、靜態(tài)嵌套類、方法內(nèi)部類、匿名內(nèi)部類。這篇文章主要介紹了Java中的匿名內(nèi)部類的相關(guān)資料,需要的朋友可以參考下
    2016-07-07
  • Java實現(xiàn)簡單猜數(shù)字小游戲

    Java實現(xiàn)簡單猜數(shù)字小游戲

    這篇文章主要為大家詳細介紹了Java實現(xiàn)猜數(shù)字游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-12-12
  • Spring循環(huán)依賴的解決方法詳解

    Spring循環(huán)依賴的解決方法詳解

    Spring的解決循環(huán)依賴是有前置條件的,要解決循環(huán)依賴我們首先要了解Spring Bean對象的創(chuàng)建過程和依賴注入的方式。依賴注入方式,我之前的博客有所分享,大家可以在看本篇文章之前進行一下小小的回顧
    2022-08-08
  • 詳解SPI在Dubbo中的應(yīng)用

    詳解SPI在Dubbo中的應(yīng)用

    通過本文的學(xué)習(xí),可以了解 Dubbo SPI 的特性及實現(xiàn)原理,希望對大家的開發(fā)設(shè)計有一定的啟發(fā)性
    2021-06-06
  • java 開發(fā)使用字符串和數(shù)字的性能分析

    java 開發(fā)使用字符串和數(shù)字的性能分析

    這篇文章主要介紹了java 開發(fā)使用字符串和數(shù)字的性能分析的相關(guān)資料,需要的朋友可以參考下
    2017-07-07
  • javaweb圖書商城設(shè)計之購物車模塊(3)

    javaweb圖書商城設(shè)計之購物車模塊(3)

    這篇文章主要為大家詳細介紹了javaweb圖書商城設(shè)計之購物車模塊的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Java上傳文件到服務(wù)器指定文件夾實現(xiàn)過程圖解

    Java上傳文件到服務(wù)器指定文件夾實現(xiàn)過程圖解

    這篇文章主要介紹了Java上傳文件到服務(wù)器指定文件夾實現(xiàn)過程圖解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-08-08

最新評論

达州市| 精河县| 开阳县| 张掖市| 永安市| 旬阳县| 崇阳县| 五华县| 陕西省| 泰宁县| 遂溪县| 汶川县| 时尚| 龙门县| 巨鹿县| 房山区| 晋城| 闸北区| 辽阳市| 安陆市| 屏南县| 屯留县| 福海县| 拉萨市| 白河县| 察雅县| 龙陵县| 崇左市| 浏阳市| 霍林郭勒市| 岑巩县| 徐州市| 扶风县| 长垣县| 抚宁县| 自治县| 独山县| 句容市| 通化市| 江安县| 牡丹江市|