Web in springBoot
This commit is contained in:
parent
6577e4b77c
commit
5fb4530b79
4 changed files with 45 additions and 60 deletions
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
4
Messageries/src/main/resources/static/css/styles.css
Normal file
4
Messageries/src/main/resources/static/css/styles.css
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
h1 {
|
||||
color: blue;
|
||||
text-align: center;
|
||||
}
|
||||
21
Messageries/src/main/resources/templates/1.html
Normal file
21
Messageries/src/main/resources/templates/1.html
Normal 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>
|
||||
|
|
@ -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");
|
||||
});
|
||||
%}
|
||||
###
|
||||
Loading…
Add table
Reference in a new issue