@RequestMapping
요청 URL을 어떤 컨트롤러 메서드로 처리할지 매핑
@Controller
@RequestMapping("/users")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/{id}")
public String getUser(@PathVariable Long id, Model model) {
User user = userService.getUserById(id);
model.addAttribute("user", user);
return "userView";
}
}
URL매핑으로,
http://~/users/{id} URL에 대한 GET 요청을 처리
https://standout.tistory.com/478
https://standout.tistory.com/477
https://standout.tistory.com/480
'JAVA > Spring' 카테고리의 다른 글
Annotation - @PostMapping (0) | 2023.04.19 |
---|---|
Annotation - @GetMapping (0) | 2023.04.19 |
Annotation - @Controller (0) | 2023.04.19 |
Annotation - @Autowired @Qualifier (0) | 2023.04.19 |
Annotation - @Component (0) | 2023.04.19 |