Web in springBoot

This commit is contained in:
ExostFlash 2025-04-02 16:11:56 +02:00
parent 6577e4b77c
commit 5fb4530b79
4 changed files with 45 additions and 60 deletions

View file

@ -0,0 +1,20 @@
package fr.teamflash.messageries.controllers
import fr.teamflash.messageries.models.StudentBean
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
@Controller
class MyController {
//http://localhost:8080/
@GetMapping("/", "")
fun homePage(model: Model): String {
model.addAttribute("name", "Bobby")
model.addAttribute("ListStudent", arrayListOf(StudentBean("Clément", 3), StudentBean("Lucien", 2), StudentBean("Maxime", 5)))
return "1"
}
}

View file

@ -0,0 +1,4 @@
h1 {
color: blue;
text-align: center;
}

View file

@ -0,0 +1,21 @@
<!doctype html>
<html lang="fr-FR">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="/css/styles.css" rel="stylesheet">
</head>
<body>
<h1 th:text="'Bonjour ' + ${name}"></h1>
<ol>
<li th:each="student : ${ListStudent}" th:text="${student.name} + ':' + ${student.note}"> </li>
</ol>
</body>
</html>

View file

@ -1,60 +0,0 @@
//Création
POST http://localhost:8080/users
Content-Type: application/json
{"login":"toto", "password":"bobby"}
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 201, "Answer not expected");
});
%}
###
//GET 1
GET http://localhost:8080/users/1
Content-Type: application/json
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Answer not expected");
});
%}
###
//Remplace
PUT http://localhost:8080/users/1
Content-Type: application/json
{"login":"blabla" , "password":"bobby"}
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Answer not expected");
});
%}
###
//GET All
GET http://localhost:8080/users
Content-Type: application/json
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Answer not expected");
});
%}
###
//Suppression
DELETE http://localhost:8080/users/1
Content-Type: application/json
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 204, "Answer not expected");
});
%}
###