From 5fb4530b79349bb44da8f5c9cda9bfbd2b6adfed Mon Sep 17 00:00:00 2001 From: ExostFlash Date: Wed, 2 Apr 2025 16:11:56 +0200 Subject: [PATCH] Web in springBoot --- .../messageries/controllers/MyController.kt | 20 +++++++ .../src/main/resources/static/css/styles.css | 4 ++ .../src/main/resources/templates/1.html | 21 +++++++ Messageries/src/test/test.http | 60 ------------------- 4 files changed, 45 insertions(+), 60 deletions(-) create mode 100644 Messageries/src/main/kotlin/fr/teamflash/messageries/controllers/MyController.kt create mode 100644 Messageries/src/main/resources/static/css/styles.css create mode 100644 Messageries/src/main/resources/templates/1.html delete mode 100644 Messageries/src/test/test.http diff --git a/Messageries/src/main/kotlin/fr/teamflash/messageries/controllers/MyController.kt b/Messageries/src/main/kotlin/fr/teamflash/messageries/controllers/MyController.kt new file mode 100644 index 0000000..f9e1130 --- /dev/null +++ b/Messageries/src/main/kotlin/fr/teamflash/messageries/controllers/MyController.kt @@ -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" + } +} \ No newline at end of file diff --git a/Messageries/src/main/resources/static/css/styles.css b/Messageries/src/main/resources/static/css/styles.css new file mode 100644 index 0000000..64ef7a2 --- /dev/null +++ b/Messageries/src/main/resources/static/css/styles.css @@ -0,0 +1,4 @@ +h1 { + color: blue; + text-align: center; +} \ No newline at end of file diff --git a/Messageries/src/main/resources/templates/1.html b/Messageries/src/main/resources/templates/1.html new file mode 100644 index 0000000..8076536 --- /dev/null +++ b/Messageries/src/main/resources/templates/1.html @@ -0,0 +1,21 @@ + + + + + + + Document + + + + + +

+ +
    +
  1. +
+ + + \ No newline at end of file diff --git a/Messageries/src/test/test.http b/Messageries/src/test/test.http deleted file mode 100644 index bcdef2e..0000000 --- a/Messageries/src/test/test.http +++ /dev/null @@ -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"); - }); -%} -### \ No newline at end of file