package com.cos.controllerdemo.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HttpRedirectionController {
@GetMapping("/home")
public String home() {
// 1만줄 있다고 가정
return "home";
}
@GetMapping("/away")
public String away() {
// 다른코드
return "redirect:/home"; // redirection이 된다 (@controller)
}
}
localhost 주소에 /away를 입력해도 home으로 돌아오는 이유를 알아보자
302 응답코드는 요청한 리소스의 url이 일시적으로 변경되었음을 의미한다