Commit 8359ae3d by Patryk Czarnik

Rozmowa z formularzem

parent f3072271
package alx.aplikacja;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class RozmowaController {
@GetMapping("/rozmowa")
public String dzialaj(String imie, Model model) {
if(imie != null && !imie.isEmpty()) {
// System.out.println("otrzymałem imię: " + imie);
model.addAttribute("wynik", "Witaj " + imie + "!");
}
return "rozmowa.html";
}
}
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>Rozmowa ze Springiem</title>
<link rel="stylesheet" type="text/css" th:href="@{/styl.css}" href="../static/styl.css">
</head>
<body>
<h1>Rozmowa ze Springiem</h1>
<form>
<label for="imie">Jak masz na imię?</label><br>
<input id="imie" name="imie" type="text"><br>
<button>Wyślij</button>
</form>
<div class="wynik" th:text="${wynik}" th:if="${wynik}">
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment