Skip to content

Commit 9a21489

Browse files
committed
Part 18: Add LoginController.java
1 parent a4fdab8 commit 9a21489

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package spring.oldboy.http.controller;
2+
3+
/* Lesson 75 - Пример передачи параметров запроса в его теле */
4+
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.ui.Model;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.ModelAttribute;
9+
import org.springframework.web.bind.annotation.PostMapping;
10+
import spring.oldboy.dto.LoginDto;
11+
12+
@Controller
13+
public class LoginController {
14+
15+
@GetMapping("/login")
16+
public String loginPage() {
17+
return "user/login";
18+
}
19+
20+
/*
21+
Lesson 75:
22+
Аннотацией @ModelAttribute("login") задаем имя ключа параметра, сами
23+
параметры при отправке формы логина будут инжектированы в loginDto.
24+
*/
25+
@PostMapping("/login")
26+
public String login(Model model, @ModelAttribute("login") LoginDto loginDto) {
27+
return "user/login";
28+
}
29+
30+
}

0 commit comments

Comments
 (0)