Commit 7f0244b0 by Patryk Czarnik

Pierwszy szablon - zwykły HTML

parent 9620656e
...@@ -8,13 +8,16 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -8,13 +8,16 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller @Controller
public class PierwszyController { public class PierwszyController {
// Gdy metoda w kontrolerze zwraca napis, a nie osiada adnotacji @ResponseBody,
// to ten napis jest traktowany jak nazwa szablonu (lub ścieżka do szablonu),
// który ma być użyty do wygenerowania odpowiedzi.
@RequestMapping("/") @RequestMapping("/")
@ResponseBody
public String index() { public String index() {
return "Aplikacja springowa"; return "index.html";
} }
// Gdy metoda posiada adnotację @ResponseBody, to, co zwraca returnem, jest odsyłane jako treść odpowiedzi.
@RequestMapping("/hello") @RequestMapping("/hello")
@ResponseBody @ResponseBody
public String hello() { public String hello() {
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Spis treści</title>
</head>
<body>
<h1>Spis treści</h1>
<h2>Przykłady pisane bezpośrednio w Controllerze</h2>
<ul>
<li><a href="/hello">Hello</a></li>
</ul>
</body>
</html>
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