-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathUserController.java
More file actions
37 lines (29 loc) · 963 Bytes
/
UserController.java
File metadata and controls
37 lines (29 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.example.VideoStreamingPlatform.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.example.VideoStreamingPlatform.Entity.UserEntity;
import com.example.VideoStreamingPlatform.Service.UserService;
@Controller
public class UserController {
@Autowired
UserService us;
@GetMapping("homepage")
public String displayHomePage() {
return "homepage";
}
@GetMapping("/api/user")
public String displayUserForm(Model m) {
UserEntity user = new UserEntity();
m.addAttribute("user",user);
return "UserForm";
}
@PostMapping("/add/user")
public String addUser(UserEntity user) {
us.addUser(user);
return "redirect:/homepage";
}
}