「Spring MVC」redirectでリダイレクト先ページに遷移する
Javaコード:
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class RedirectExampleController {
@RequestMapping(value = “/redirect", method = RequestMethod.GET)
public String authorInfo(Model model) {
// Write some code
return “redirect:/hello";
}
}
URLの確認
http://localhost:8080/HelloSpringMVC/redirect