請教下各位
@GetMapping("/test")
public String test(Model model){
String name = "test";
model.addAttribute("name",name);
return "redirect:/test.html";
}
@GetMapping("/test.html")
public void demo(String name){
System.out.println(name);
}
結果 name=null
是不是可以理解,model類似request,只支持跳轉,不支持重定向?
那如果需要把物件重定向到下一個頁面,只能用session帶過去嗎?比如登錄之后,重定向到主頁,我得把用戶物件帶過去,查有關他的資料
我參考的這篇博客
https://blog.csdn.net/itcast_cn/article/details/87606274
他的結論是 model將第一次請求中設定的屬性值當做新的請求引數傳遞給了下一次轉發路徑所需引數中了。
不知道是不是我測驗的有問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/204123.html
標籤:Apache
上一篇:圖片與鏈接問題
